Microsoft Interview Question for Software Engineer in Tests






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

Assuming the array is of size NxN and N is an odd number.

over = 0;
for(i=0;i<=N && !over;i++)
{
j=0;

for(j=0, player = arr[i][j]; player == a[i][j] ; j++) //check row
if(j==N) over = 1;
for(j=0, player = arr[j][i]; player == a[j][i] && !over ; j++) // check col
if(j==N) over = 1;
if(i==1 || i == (N+1)/2) //check diagonal and set if over
}

print "winner is " player;

- onion834 September 29, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

can some one please explain this?

- Pari October 02, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I would like to change onion834 code..

int diagonalflag=1;
for(i=0;i<N && !over; i++)
{
j=0;
for(j=0;j<N && arr[i][j]==player;j++) //check row

if(j==N) over=1;

for(j=0;j<N && arr[j][i] == player; j++) //check column

if(i==N) over=1;

if(arr[i][i]!=player){
diagonalflag = 0;
}
}

if(over==1 || diagonalflag==1){
print("player wins");
}

//can be modified for 2 players

- Guddu October 11, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bool FindWinner(int a[][],int n)
{
bool dial=true;
bool dia2=true;
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)//check row
{
if(a[i][j]==0)//this row is failed
break;
if(j==n-1)//this row is successful
return true;
}
for(int j=0;j<n;++j)//check col
{
if(a[j][i]==0)//this col is failed
break;
if(j==n-1)//this col is successful
return true;
}
if(dia1&&!a[i][i])
dia1=0;
if(dia2&&!a[i][n-1-i])
dia2=0;
}
if(dia1||dia2)
return true;
}

- gandalf October 16, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

check across any diagonal.
check whereever possible in the following dirs:
horizontal
vertical
diagonal starting from left top
diagonal starting from right top.

- Anonymous October 26, 2008 | 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