Microsoft Interview Question for Software Engineer / Developers






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

A[i][j] = A'[M-j-1][i]

- ahj August 29, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

when j = 3 ( as M = 3) what will be the result?

- Anonymous August 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

j by definition is >= 0 and < M

- ahj September 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@ahj this is really correct answer
A[i][j] = A'[M-j-1][i]

one quick question however...
apart from creating and observing this pattern... is there any other way.. algebric to reach this answer

- Amit September 12, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I have the same question in mind.

- @Amit September 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

A[i][j] = A[N-j][i]

- leehom liang August 29, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

A[i][j] = A[N-j-1][i]

- Anonymous August 29, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The relation will be,
A[i][j] = A'[M-j+1][i]

- tito August 29, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

here M=3
so ur solution is wrong..

- saumils1987 August 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@saumils1987 Could you please tell me in which case this will give incorrect result?

- Anonymous August 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

A[i][j] = A'[M-j][i]
This is the right solution

- XXX September 06, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

A[i][j] = A'[M-j+1][i] is wrong
Here M = 3, and N= 2
using above relation A[0][0] =A'[4][0]

So,
A[i][j] = A'[M-j][i] is correct answer

- gang September 17, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@gang
A[i][j] = A'[M-j][i] is not correct. take i = 0 and j = 0;
A[0][0] = A'[3][0] but only 3 rows but not 4 in A'
I think the answer is A[i][j] = A'[N-j][i]
correct me if i'm wrong

- rkt September 19, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Rotation is equal to a transpose, followed by a "flop" around the horizontal axis:
A[i][j] => A[j][i] => A[M-j-1][i]
provided the first set of brackets correspond to the column number and the indexes starts at 0

- lupuslupus August 30, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Everything was written before is wrong. That's right
A[i][j] => A'[M - j][N - i - 1]

- Interoper August 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

including yours...

- Mahesh September 03, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

interoper ur solution is wrong as well ..
only ahj's solution si correct..

- saumils1987 August 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Given N=2,M=3
The relation between A[] and A'[] is
A[i][j]=A'[(N*(j+1))%M][i]

- praneeth September 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Surprised so many people got wrong for such a simple question
Ah's solution is the only right one

- Anonymous September 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A[i][j] = A [M-j+1][i]

- louis.fernando September 07, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A[i][j] = A [M-j+1][i]

A[i][j] = A[j][M-i+1]

- louis.fernando September 07, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A[N][M] = A'[M][N] only that M decreases.

- Shilpa September 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

its A[N-j-1][i] not A[M-j-1][i]

- Anonymous October 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A[i][j] = A'[2-j][i]

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

A[i][j] = A'[N-j][i]

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

bbhusal1 answer is correct

- Anonymous October 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A'[i][j] = A[j][i]
A'[i][j] = A'[M-1-i][j]
where i ranges from 0 - M/2
and j ranges from 0-N

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

The correct answer is:

A[i][j] = A'[N-j+1][i]

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

I got that A' is the result of the rotation on A in a anti clockwise manner. Could anyone please explain the problem?

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

A[i][j] = A'[N-j][i]

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

It is like cycle detection algorithm:
Lets say in initial matrix (row,colun) -> (i,j)
So now index in array = COLS * row + column.
Now the same index after transition will be index = ROW*col + row.
That is in the trasitioned matrix row and columns are interchanged and also the new matrix order is also reversed.

Ex (1,2,3,4,5,6) becomes now (1,4,2,5,3,6) (Represented in a 2 X 3 matrix)
But from the question these are again reversed.

So ow the solution becomes
newi = (COL - ROW*col + row) / COL
newj = ( COL - ROW*col + row.) / COL

This logic might be complex , If some one has a better logic please share

- Wolverine October 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

It is like cycle detection algorithm:
Lets say in initial matrix (row,colun) -> (i,j)
So now index in array = COLS * row + column.
Now the same index after transition will be index = ROW*col + row.
That is in the trasitioned matrix row and columns are interchanged and also the new matrix order is also reversed.

Ex (1,2,3,4,5,6) becomes now (1,4,2,5,3,6) (Represented in a 2 X 3 matrix)
But from the question these are again reversed.

So ow the solution becomes
newi = (COL - ROW*col + row) / COL
newj = ( COL - ROW*col + row.) / COL

This logic might be complex , If some one has a better logic please share

- Wolverine October 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry newJ = ( COL - ROW*col + row.) % COL

- Wolverine October 11, 2012 | Flag


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