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
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

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
Hash Map
Geometry
GCD Normalization
Arrays
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported