Microsoft Interview Question for Software Engineer in Tests






Comment hidden because of low score. Click to expand.
0
of 0 vote

4)Ans:

Let A,B,C,D,E,F,G,H are 8 teams.

Mimum number of matches to win for qualify = 4

Teams win Loss
A 14 0
B 12 2
C 10 4
D 4 10
E 4 10
F 4 10
G 4 10
H 4 10

Maximum number of matches won by team when not qualify = 10

Teams Win Lost
A 10 4
B 10 4
C 10 4
D 10 4
E 10 4
F 4 10
G 2 12
H 0 14

- Anonymous February 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

cant max. matched won be
A 13 1
B 13 1
C 13 1
D 13 1
E 13 1
F 13 1
G 13 1
H 13 1

- Anonymous February 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

the league table can never look like this. one team has to win and the other has to lose. the sum of total points won by all teams has to equal 56.

- Anonymous February 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

we can also have like

11 3
11 3
11 3
11 3
11 3
1 13
0 14
0 14

so it will be max 13 n not qualified

- sriks March 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

edit for prev response it will be 11 not 13..

and for min matched for qualifying can be something like this

14 0
14 0
14 0
4 10
3 11
3 11
2 12
2 12

hence it will 4

- sriks March 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

every thing is BS..except for the first anon...he got it write..

sriks ur missing a small point..14 wins means every other team has to lose and hence the 2nd cant have 14 wins again..its a simple math thou...

- anon March 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The answer given by the first guy is correct. Don't understand why are there so many people questioning it and more interestingly, some1 even gives his code...
Because after the analysis by a human brain, the answer can be given immediately, so it's a problem that can be solved with O(0) time and O(0) storage..
So why do they write a code to solve a question that can be solved with O(0) time and O(0) storage?

- fentoyal April 24, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

char* Replace(char* src, char* from, char* to)
{
int count;
char* temp;
int i,j,k,l,p;
for(i=0,p=0;i<strlen(src);i++,p++)
{
count =0;
temp[p]=src[i];
if(src[i]==from[0])
{
count++;
for(j=1;j<strlen(from);j++)
if(src[i+j]==from[j])
count++;
if(count==strlen(from))
for(k=i,l=0;k<i+strlen(to);k++,l++)
temp[k]=to[l];
p=p+strlen(to)-1;
i=i+strlen(from)-1;
}
}
return temp;
}

int main(void)
{
char str[40];
char find[10];
char replace[10];
char *nstr;
printf("Enter the original string: ");
scanf("%s",&str);
printf("Enter the find string: ");
scanf("%s",&find);
printf("Enter the string to replace: ");
scanf("%s",&replace);
nstr = Replace(str,find,replace);
printf("The modified string is: %s \n",nstr);
return 0;
}

- Anonymous February 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

temp is uninitialized, and you are trying to write to temp[p] ? This code will crash.

- andy February 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

//for questio one this code below should be fine ......although it could be made better by involving the malloc functions by determining the size exactly.......

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

char* Replace(char* src, char* from, char* to)
{
int count;
char* temp;
int i,j,k,l,p;
for(i=0,p=0;i<strlen(src);i++,p++)
{
count =0;
temp[p]=src[i];
if(src[i]==from[0])
{
count++;
for(j=1;j<strlen(from);j++)
if(src[i+j]==from[j])
count++;
if(count==strlen(from))
for(k=i,l=0;k<i+strlen(to);k++,l++)
temp[k]=to[l];
p=p+strlen(to)-1;
i=i+strlen(from)-1;
}
}
return temp;
}

int main(void)
{
char str[40];
char find[10];
char replace[10];
char *nstr;
printf("Enter the original string: ");
scanf("%s",&str);
printf("Enter the find string: ");
scanf("%s",&find);
printf("Enter the string to replace: ");
scanf("%s",&replace);
nstr = Replace(str,find,replace);
printf("The modified string is: %s \n",nstr);
return 0;
}

- Anonymous February 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char *replace(char *str, char *find, char *replace)
{
char *p=NULL;
char *out=NULL;
if(NULL==str || NULL ==find || NULL==replace){
printf("\n invalid param");
return NULL;
}
if(NULL == (p=strstr(str, find))){
printf("\n find not present in str");
return NULL;
}
else{
int len=0;
len= p-str + strlen(p+strlen(find)) + strlen(replace);
out=(char *)malloc(len +1);
if(out==NULL){
return NULL;
}
*p='\0';
strcpy(out, str);
strcat(out, replace);
strcat(out, p+strlen(find));

}
return out;

}

- pg February 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

this will work for only the first occurrence of the pattern....not all

- Anonymous February 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hi Guys,

The written test of Microsoft was on 13th Feb 2011 in Bangalore.
Thanks for the written test questions.

Can you please send me the questions for the INTERVIEW please which held on 19-20 Feb 2011?

I will be really grateful to you.

- Sandeep Shivhare February 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hi ajitpec,

The written test of Microsoft was on 13th Feb 2011 in Bangalore.
Thanks for the written test questions.

Can you please send me the questions for the INTERVIEW please which was held on 19-20 Feb 2011?

You can send me the questions in my email or you can just call me.

OR, just give me your cell number, I will call you directly.
I will be really grateful to you.

Sandeep Shivhare
8880994330
sandeep_shivhare19@yahoo.co.in

- Sandeep Shivhare February 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char* replaceString(char* str, char* find, char* replace)
{
	int strLen = strlen(str);
	int findlen = strlen(find);
	int replacelen = strlen(replace);	
	char* newStr = (char *)malloc(sizeof(char)*strlen(str)*( (replacelen/findlen)+1)+1);
	*newStr = '\0';

	int index = 0;
	int done = 0;
	
	while(*(str+index))
	{
		//printf("%c,%d\n",*(str+index),index);
		if(*(str+index) == *find || !*(str+index+1))
		{
			int newlen = strlen(newStr);

			if(*(str+index) != *find)
			{
				memcpy(newStr+newlen,str+done, index-done+1);
				*(newStr+newlen+index-done+1) = '\0';
			}
			else
			{
				memcpy(newStr+newlen,str+done, index-done);
				*(newStr+newlen+index-done) = '\0';
				done = index;

				if(index+findlen <= strLen)
				{
					bool match = true;
					for(int i = 0 ; i < findlen ; i++)
					{
						if(*(str+index+i) != *(find+i))
						{
							match = false;
							break;
						}
					}

					if(match)
					{
						index += findlen;
						done = index;
						newlen = strlen(newStr);
						memcpy(newStr+newlen,replace,replacelen);
						*(newStr+newlen+replacelen) = '\0';				
					}
				}
			}
			//printf("%s\n",newStr);
			//getchar();			
		}
		index++;
	}
	return newStr;
}

- Anonymous March 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Solution for problem 1

char * replace(char *str,char *find,char *replace)
{

char *temp = (char *)malloc((sizeof(char)*(strlen(str)+strlen(replace)-strlen(find))));

char *i;
i=strstr(str,find);
if(i>=0)
{
strncpy(temp,str,(i-str));
strcat(temp,replace);
strcat(temp,i+strlen(find));
return temp;
}
return str;
}

- msankith October 26, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More