Microsoft Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

If you do merge sort, then you can check if the pivot point is at n/2 in the entire array, if yes, then return. I should be careful about n (odd or even).

Then use randomly merge sort, you should get O(log(n)) on average, however worst case is still O(n). You cannot do better.

- Anonymous December 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

Microsoft didn't ask you that. Stop trying to cheat on your randomized algorithms homework.

- Anonymous April 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It does sound like homework. What is especially suspicious is the usage of the words "las vegas". Interviewers rarely know such things :-P Just kidding. Seriously, though, having that in the question does raised red flags.

- Anonymous April 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

So, to be clear, at least n/2 of the elements are all the same element, and the other elements are all distinct from one another?

- Anonymous April 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

is that array s sorted of what kind of array it is? if it is a random array with repeated elements distributed randomly then i dont think there will be any algorithm to find the element rather than just traversing the array...

Correct me if am wrong!

- vinodhian April 30, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use majority number algorithm and check whether majority number count is actually n/2 or more

- crystal.rishi2 October 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

is that array s sorted of what kind of array it is? if it is a random array with repeated elements distributed randomly then i dont think there will be any algorithm to find the element rather than just traversing the array...
Correct me if am wrong! (c)

WTF, the guy told you, LAS VEGAS ALGORITHM. noone read the question?

- vlad April 14, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

fun(a,start,end){
if(a[start]==a[end]){ //found repeated
return a[start];
}else{
mid = start + (end-start)/2
fun(a,start,mid+1) //since n/2 elements are repeated so take n/2+1 window size
fun(a,mid-1,end)
}
}
//check the boundary conditions.

- skg May 09, 2012 | 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