Microsoft Interview Question
Q2. Was any run time efficiency restriction specified?
One way to do this could be-
char chr = 's'; // char to find
char *ptr1 = str;
ptr2 = ptr1;
while(*ptr1 != '\0')
{
if(*ptr1 == chr) ptr2 = ptr1;
ptr1++;
}
in case it was C# then,
len = str.Length();
while(len >= 0)
{
if(str.chatAt(len) == 'x') // just took this as a constant
Console.WriteLine("last occurance at " + len+1);
len--;
}
both would work out to be the same (best case) if for the former, the input were: "opqrs" and for the later the input were to be: "xyzwu".
this questions seems really ambiguous. what does the textbox do? display an ad on the msn page?
- nunbit romance November 22, 2007