Microsoft interview question

Given an array of point structure element whose X and Y values are both int, write a boolean function to decide whether there is any midpoint(at least 1) of any two points in the array whose X and Y coordinate value are all integer.

Interview Answers

Anonymous

1 Oct 2017

First discuss the n square naive algorithm and then the interviewer give me a hint on using pattern to solve the question (even odd pattern ). Then easy complete the question in O1

Anonymous

12 Oct 2017

can you discuss the solution in detail?

Anonymous

12 Oct 2017

If there are more than four points, just return true, because there are only 4 patterns for the 2-dimensional situation that are (odd, odd) (odd, even) (even, odd) (even, even). Then all these patterns can be derived to n-dimensional question. I think the interview is more focusing on testing your logic reasoning and how you deliver your results with the interviewer instead of the difficult algorithm.