Collect Points

Collect Points is a Flexport interview question for a coding interview. You’re given n players and m points on a 1-D number line, with positions in arrays players and points. Each second, a player moves 1 unit left/right or stays. A point is collected when any player visits its location. The problem asks for the minimum time required to collect all points with optimal, simultaneous movement.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: