Most Points on a Line

Talk it through out loud with your AI coach.

The problem

  • hard
  • Pro

You're given a list of points on a flat plane with whole-number coordinates, possibly with repeats. Find the largest number of points that lie on one straight line. Explain your approach, how you represent a line's direction exactly, and the cost.

What a strong answer covers

  • Fixing one point at a time and grouping the others by direction.
  • An exact, comparable way to write a direction, including straight up and down.
  • What to do with duplicate points.
  • The cost compared with a brute-force check.

Common mistake: Keying the map by a floating-point slope, so rounding splits points on one line and vertical lines divide by zero.

Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.

Practise it out loud