Help N people cross a bridge puzzle
Filed under Arcesium
Free read 1 of 3Understand that the goal is to minimize total time for all individuals to cross.
The question
Solve the classic bridge and torch puzzle to help n people cross a bridge with a single flashlight under strict time constraints.
Constraints
- At most 2 people can cross at once.
- A flashlight must be carried back and forth.
- Crossing speed is determined by the slower person.
Examples
- Input
- Times: [1, 2, 5, 10]
- Output
- 17
- Why
- Fastest strategy for 4 people with given times.
Approach
Understand that the goal is to minimize total time for all individuals to cross.
For 4 people (a <= b <= c <= d), two strategies compete: send two fastest to set up, or send two slowest together. Usually, 2*b vs a+c determines the optimal move.
For n people, sort the array and greedily send the two fastest back or forth to ferry the two slowest across together.
Tips
- What they are testing: Check edge cases with 1, 2, or 3 people.
- Common mistake: Assuming the fastest person must always accompany every single person back.
Related Arcesium questions
Collected from public candidate posts and coding forums. Updated Nov 2026.