## 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

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

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?

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

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

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.

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.

### 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.