Travel Distance on Scooters
Reported by candidates from TikTok's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The TikTok OA reported in July 2026 has a scooter problem that looks like a story and plays like a simulation. Most first attempts die on one detail: what happens when a ride would overshoot finish, or when the next scooter sits inside the stretch you just rode past. You sort the scooters, walk a pointer, and add up ride distance. That's the whole thing. It's short, but the edge cases bite. If you blank mid-assessment, StealthCoder runs invisibly on your screen as a safety net and hands you the logic.
The problem
Imagine that you are standing at the starting point of a straight street and are trying to reach the end of the street. The street is represented by a number line starting at 0 and ending at finish, where finish > 0. Electric scooters are scattered along the street. The array scooters stores their locations, where scooters[i] is the position of the i-th scooter. Each scooter can travel at most 10 points to the right before its battery is exhausted. You must follow this exact algorithm: From your current position, walk to the nearest scooter to your right. If there is no scooter to your right, walk directly to finish. Ride that scooter as far as possible toward finish, using all of its remaining range. If you have still not reached finish, repeat from step 1. Return the total distance that you travel while riding scooters. You are not required to provide the optimal asymptotic solution. A solution with time complexity no worse than O(scooters.length * finish) fits within the limit. Function travelDistanceOnScooters(finish: int, scooters: int[]) → int Examples Example 1 finish = 23 scooters = [7, 4, 14] return = 19 From position 0, the nearest scooter to the right is at 4, so you ride from 4 to 14 for 10 scooter-distance. From 14, the next scooter to the right is at 14 itself, so you ride from 14 to 23 for 9 more. The total scooter distance is 19. Example 2 finish = 27 scooters = [15, 7, 3, 10] return = 20 You first walk to the scooter at 3 and ride it to 13. Then the nearest scooter to the right is at 15, which takes you to 25. After that, there are no more scooters to the right, so you finish on foot. The scooter distance is 10 + 10 = 20. Example 3 finish = 10 scooters = [] return = 0 There are no scooters on the street, so you travel the entire route on foot and accumulate no scooter distance. Constraints 1 <= finish <= 1000 All scooter locations are distinct integers on the street.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is sort plus simulation. Sort scooters ascending, keep a current position starting at 0, and loop. Find the first scooter with position at or past your current position. If none exists, stop. Otherwise ride min(10, finish - scooterPos) and set your position to scooterPos + that ride. Add the ride to the total. The pitfall is capping at finish. A scooter at 20 with finish 23 only gives 3, not 10. The second pitfall is skipping scooters you've already passed. Example 1 shows a scooter at 14 right where you land, so the comparison must be greater than or equal. Also handle scooters beyond finish, if any appear. The stated bound of scooters.length * finish is generous, so a simple scan each round passes. If the live OA has you freezing on the boundary logic, StealthCoder is the hedge that reads the problem and gives you the clean loop.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Travel Distance on Scooters cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass TikTok's OA.
TikTok reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Travel Distance on Scooters FAQ
What's the trick in the TikTok Travel Distance on Scooters problem?+
Sort the scooters, then simulate exactly as written. Track your position, jump to the next scooter at or ahead of you, ride min(10, finish - scooter), and move your position to where the ride ends. No clever math needed. The work is in the boundary handling.
Why do people fail this one on the first attempt?+
Two reasons. They forget to cap the ride at finish, so they count 10 even when only 3 remain. Or they use strictly greater when picking the next scooter, which skips a scooter sitting exactly where you landed, like the one at 14 in example 1.
How hard is it really?+
Easy. It's a sorting and simulation problem with a generous complexity allowance. Finish is at most 1000, so even a naive scan each round is fine. The difficulty is reading the rules carefully, not the algorithm.
What happens with an empty scooters array?+
You return 0. Example 3 covers it. With no scooters you walk the whole street, and walking adds nothing to the scooter distance. Your loop should exit immediately when it finds no scooter ahead of you.
How do I prepare for this in 48 hours?+
Write the simulation by hand once with examples 1 and 2, then test odd cases: a scooter near finish, a scooter exactly at your landing spot, and an empty array. Check unsorted input. That covers nearly every way this problem breaks.