Solved LeetCode program · 869 of 1,000
#1184 · Distance Between Bus Stops
Original English source
The gaps is a list of 1, 2, 3, and 4. The start is 0. The finish is 1. The size is 0. The total is 0.
For each gap in gaps.
Add 1 to size. Add gap to total.
The clockwise is 0. The spot is start.
Repeat while spot is not finish.
Increase clockwise by item spot of gaps. Set spot to (spot plus 1) modulo size.
The other is total minus clockwise. The best is clockwise. If other is less than best, set best to other.
Show best.
Expected stdout
1