Most Delivery Drop Points Lying on a Single Drone Flight Line
Last updated: November 29, 2026
Quick Overview
Given integer coordinates of delivery drop points, return the maximum number of points that lie on one straight line, which tells Prime Air planners the best single straight flight path.
Amazon
November 29, 20260
0
0 solved
Given integer coordinates of delivery drop points, return the maximum number of points that lie on one straight line, which tells Prime Air planners the best single straight flight path.
An Amazon onsite hard problem themed on Prime Air drone routing. The interviewer checks that you hash slopes exactly (reduced integer pairs, not floats), normalize signs, and deal with duplicate points and vertical lines.
What the Interviewer Expects
- Fix an anchor point and hash slopes to every other point
- Represent slopes as reduced (dy, dx) with gcd and a sign convention
- Explain why floating-point slopes are risky
- Count duplicates of the anchor separately
- Analyze the O(n^2) time bound
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return the actual line, not just the count?
- Can you do better than O(n^2) if most points are known to be collinear?
- What if coordinates are floats from GPS with measurement noise?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of [x, y] integer pairs, may contain duplicates, n up to a few thousand. Output: the largest number of points on a common line. One point gives 1; zero points give 0....
High-Level Design
Every line through at least two points passes through some anchor point. For each anchor i, compute the direction to each later point j as (dy, dx) divided by their gcd, with a sign convention so op...