Microsoft Interview Question for Software Engineer / Developers


Team: MS Office Platform
Country: India
Interview Type: In-Person




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

Two points are colinear if they
1) pass through same point.
2) Have same slope.

pick one point and calculate slope of each point w.r.t this point. Store all these in an array. Sort this array. find duplicates. (there will be different sets). each set will be of collinear points. (Since we have calculated this wrt one point the first condition is prechecked)

Second part is tough man

- Sugarcane_farmer May 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

3-d also follows same logic. Whereas for 2-D we will have x-y slope, for 3-D we can have x-y slope and y-z slope. O(k*n^2) complexity for kth dimension. Is there are better algo?

- gi May 25, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Say points are like this in 2-D, and pick x1 to find the slope with respect to other points. Now i see that x2 and x3 are colinear with x1, but there exists one more set y1 y2 y3 y4 which has more colinear points. So shouldn't we maintain a count map with respect to all points and return the maximum ?

x1 x2 x3

y1 y2 y3 y4

- Vib December 30, 2014 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Points will be collinear if there slop will be same. Take origin and calculate slop of all points with respect to origin. Now problem reduces to find maximum frequent words. that can be done in simple O(n) with using couting variable.
Similarly for 3d this can be extend, here we need to take 2 angle to define a line.

- Anurag Jain October 13, 2014 | 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