HARDasked at 11 companies

Max Points on a Line

A hard-tier problem at 29% community acceptance, tagged with Array, Hash Table, Math. Reported in interviews at Waymo and 10 others.

Founder's read

Max Points on a Line is a hard geometry problem that shows up in interviews at Waymo, Google, Meta, LinkedIn, and other top-tier companies. The acceptance rate sits around 29%, which means most candidates miss the insight on their first attempt. The problem asks you to find the maximum number of points that lie on the same line. It's not a trick question, but the obvious brute force path leads to floating-point precision nightmares. You need a hash table and slope math to pass. If you hit this problem cold in your OA and blank on the angle calculation, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
11
Difficulty
HARD
Acceptance
29%

Companies that ask "Max Points on a Line"

If this hits your live OA

Max Points on a Line is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The trap is trying to store slopes as decimals. Floating-point precision breaks the hash table approach immediately. The correct move is to represent each slope as a reduced fraction: for two points, compute (dy, dx) and reduce both to lowest terms using GCD. Use a hash map keyed by this reduced slope pair to count collinear points. For each starting point, iterate through all other points, compute their slopes relative to your anchor, and track the maximum count. Watch the edge cases: duplicate points, vertical lines (dx=0), and the starting point itself all need special handling. Array and Hash Table are your core tools here; Geometry and Math just describe the domain. The problem combines all four topics, which is why it's hard and why candidates hesitate. StealthCoder is the safety net if you blank on the GCD reduction trick during your live assessment.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Max Points on a Line recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Max Points on a Line interview FAQ

Why can't I just use decimal slopes in a hash map?+

Floating-point arithmetic is inexact. Two mathematically identical slopes often produce different decimal values due to rounding, so your hash map misses collisions. Using reduced fractions (dy/gcd, dx/gcd) as a tuple key guarantees exact matching for parallel or collinear points.

Is this still asked at Google, Meta, and other top companies?+

Yes. It appears in most reports from Waymo, Google, Meta, and LinkedIn. The 29% acceptance rate shows it's still a strong filter. Companies use it to test geometric intuition and hash table fundamentals under precision constraints.

What's the time complexity and is it acceptable?+

O(n^2) for the nested loop over all point pairs, with O(1) hash operations per slope. For most interview constraints (n less than 300), this passes. Brute force O(n^3) checking all triples will time out.

How do I handle duplicate points and vertical lines?+

Count duplicates separately before the main loop; they lie on every line through their location. Vertical lines have dx=0 and dy non-zero; your GCD logic still works. Always add 1 to account for the anchor point itself in your final count.

Is this a problem I should drill before my OA, or is it rare enough to skip?+

With 11 companies reporting it and a 29% pass rate, it's high-risk to ignore. Drill the GCD-based slope reduction once so you recognize it live. If you don't nail the pattern during your assessment, StealthCoder hedges the gap.

Want the actual problem statement? View "Max Points on a Line" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.