Max Points on a Line

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

Essentially this problem is equivalent to find all unique lines. Note that each line can be represented by a pair: slope and a fixed point. Here, we use the point where y = 0. If y = 0 is impossible, we use the point where x = 0. Also, we use a map to store the line and the points which lie on this line.


Comments

Popular posts from this blog

Maximum Gap

[ITint5] Maximum Subarray for a Circular Array

[CC150] Chapter 8 Object-Oriented Design