Fewest Barcode Scanners to Cover Every Package on a Conveyor

Last updated: November 29, 2026

Quick Overview

Each package on a conveyor occupies a span [left, right] of belt positions. A scanner placed at position p reads every package whose span contains p. Return the minimum number of scanners that read every package.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Each package on a conveyor occupies a span [left, right] of belt positions. A scanner placed at position p reads every package whose span contains p. Return the minimum number of scanners that read every package.

An Amazon technical screen greedy question about placing fixed scanners along a fulfillment center conveyor. The interviewer checks that you sort by right endpoint and place a scanner at the end of the first unread package, and that you can explain why that point is a safe choice.

What the Interviewer Expects
  • Reduce to stabbing all intervals with the fewest points
  • Sort spans by right endpoint
  • Place a scanner at the right end of the first unread span
  • Skip all spans that contain that point
  • Justify the greedy choice
Key Topics to Cover
Greedy
Interval Stabbing
Sorting
Intervals
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
  • What if each scanner has a fixed read radius rather than a point?
  • Return the scanner positions as well as the count.
  • What if some positions are blocked and cannot hold a scanner?
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 [left, right] closed spans, possibly overlapping and unsorted. Output: minimum number of integer or real points such that each span contains at least one point....

High-Level Design

Sort spans by right endpoint. The span that ends first must be covered by some point at or before its right end. Placing the scanner exactly at that right end is never worse than any earlier point, be...


Submit Your Answer
Markdown supported