My Blog List

[Leetcode Solution] Max Points on a Line



Analysis

  • Firstly find out the identical points and count the number of each distinct point. Enumerate all the lines consisted of two distinct points. Count the number of points lays on this line and return the maximum number.
  • Duplicated points might occur
  • The number of distinct point might less then 3

Note

  • How to check if three points lie on the same line  
Second Version At Leetcode Pass 2
  • How to check if three nodes stand in a line taking into consideration that it might be a line parallel to the coordinate axis
(a.y-b.y)*(b.x-c.x) == (a.x-b.x)*(b.y-c.y) 

  • How to use user defined structure in std::hash by define comparison class by overload ( ) operator. 

Code



Second Version At Leetcode Pass 2

UPDATED AT LEETCODE 2ND PASS

No comments:

Post a Comment

Enter you comment