204. Given two strings s1 and s2 ......
Microsoft Interview Questions and Answers
(Continued from previous question...)
204. Given two strings s1 and s2 ......
Question:
Given two strings s1 and s2. Write the program to delete all the characters of s2 from s1.
maybe an answer:
{
void remove( char* s1, char* s2 )
{
bool s2Chars[256];
int source = 0, dest = 0;
int length = strlen(s1);
for( int i=0; i<256; ++i )
{
s2Chars[i] = false;
}
while( s2[source] )
{
s2Chars[s2[source]] = true;
++source;
}
source = 0;
while( source<length )
{
if( !s2Chars[s1[source]] )
{
s1[dest] = s1[source];
dest++;
}
source++;
}
s1[dest] = 0;
}
}
(Continued on next question...)
Other Interview Questions
- 144. If [a1,a2,a3...,an,b1,b2...bn] is given input change......
- you are given a linked list and you are supposed to take it as input and return
- Find inorder successor and predecessor of a given node in BST ......
- Finding number of on bits (1 bits) given an integer..discuss the various approaches..what is the best one?
- 159. Given array of n integers and given a number X .......
- 172. Write a function which determines whether provided string matches specified pattern .......
- Given number 1,2,3,4,5,6,7,8,9 find all sets that sums up to 10.....
- You are given a string sequence and program need to output the number......
- 195. How will you delete duplicate odd numbers from a linked list?
- 262. Merge two sorted singly linked lists into one without using extra.....
- More...
|