Microsoft Interview Question for Software Engineer in Tests






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

I dont think it can be done in anything less than O(n^2)

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

{{1.sort the 2d array of 0 and 1 in o(n). as 2d array can be thought as a 1d array.
2.assume indexes from 1 to N.

begin at a[1,N]
for any a[row,index]
if a[row,index]==0 row++;
if a[row,index]==1 col--;count++;

do above steps untill we transcend any boundary of 2d array..
}}

- spandan February 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

complexity for above algo is O(n)(step1)+ O(n)(step2)=O(n)

- spandan February 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Please feel free to explain how your step1 is O(n).
Even if i say every row took O(n) time still its O(n2) operation.

(if they are already sorted a guaranteed O(n) solution exists)

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

The question states that we have to print all the cells which are switched on ... So in a 10*10 matrix, if the value of the entry 7*7 is 1 we have to print that 7*7 is on.
If we sort the entries then we loose the fact the row and column nos that these entries came from

- abhimanipal May 04, 2010 | 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