Linear Warehouse Drone Delivery
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 August 2026 hands you a number line, a pile of charging stations, and a drone that flies 10 units. The input hint says O(stations.length * target) is fine, so nobody's asking for anything clever on scale. It's a simulation with a sort up front. If you've got an invite for the next day or two, this one's about reading the protocol exactly and not overthinking it. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the logic below is short enough to hold in your head.
The problem
You are designing a delivery system that uses drones in a linear warehouse. The warehouse is a number line that starts at position 0 and ends at position target, where target > 0. Charging stations are placed at positions given by the array stations. A fully charged drone can carry the cargo at most 10 units to the right. For example, a drone launched at position 12 can reach any position through 22, inclusive, but cannot reach position 23. Starting with the cargo at position 0, repeat this protocol until the cargo reaches target: Carry the cargo on foot from its current position to the nearest charging station at or ahead of that position. If there is no such station before the target, carry the cargo directly to target. Launch a fully charged drone from that station and send the cargo as far as possible toward target, up to 10 units. If the target has not been reached, walk to the position where the drone landed, retrieve the cargo, and repeat. Return the total distance over which the cargo is carried on foot. Walking performed without the cargo is not included. A solution with time complexity no worse than O(stations.length * target) fits within the execution time limit. Function minimumFootDistance(target: int, stations: int[]) → int Examples Example 1 target = 23 stations = [7,4,14] return = 4 Carry the cargo from 0 to station 4, adding 4. The drone carries it to 14. A drone can launch immediately from the station at 14 and reach 23, so no more cargo-carrying on foot is needed. Example 2 target = 25 stations = [20,10,0] return = 0 The cargo begins at station 0. Drones launched from stations 0, 10, and 20 carry it all the way to the target, so the cargo is never carried on foot. Example 3 target = 28 stations = [25,3] return = 15 Carry the cargo 3 units to station 3, then the drone carries it to 13. Carry it another 12 units to station 25, whose drone reaches the target. The total is 3 + 12 = 15. Constraints target > 0. Every value in stations is a position on the warehouse line from 0 through target. The answer fits in a signed 32-bit integer.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Sort the stations. Keep a position pos starting at 0. Loop: find the first station at or ahead of pos. If none exists, add target - pos to the answer and stop. Otherwise add station - pos to the answer, set pos to station + 10. If pos >= target, stop. That's it. Check example 3: pos 0, station 3, walk 3, land at 13. Next station at or ahead of 13 is 25, walk 12, total 15, and 25+10 covers 28. The pitfalls are small. Don't count the drone flight as walking. Don't forget that landing on a station means zero walking. Don't forget the no-station case walks to target. A pointer that only moves forward gives O(n log n) after sorting, but the scan-per-step version also passes the stated limit. If you freeze in the live OA, StealthCoder gives you this loop as a hedge, though you can write it in five minutes.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Linear Warehouse Drone Delivery 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.
Linear Warehouse Drone Delivery FAQ
What's the trick in Linear Warehouse Drone Delivery?+
There isn't a deep one. Sort the stations, then simulate the protocol. At each step walk to the next station at or ahead of your position, fly 10 units, repeat. Walking distance only accrues between landing spots and the next station, or to the target if none remain.
How hard is this TikTok OA question really?+
Easy to medium. The logic is a greedy simulation with a sort. The difficulty is reading the protocol carefully, especially the rule about stations at or ahead of the landing spot and the no-station fallback to the target.
Do I need anything faster than the simple simulation?+
No. The problem says O(stations.length * target) fits the limit. A sort plus a forward-moving pointer is O(n log n), and even rescanning stations each step is well inside that bound.
What edge cases should I test?+
Test a station at position 0, which gives zero walking at the start. Test a landing spot that exactly equals a station. Test no stations ahead, so you walk to target. Test a target under 10, where the drone isn't needed if you launch from 0, and where you must still walk if no station exists.
How do I prepare in 48 hours for this kind of OA?+
Practice simulation problems where you follow a stated protocol exactly. Write the loop by hand, trace all three examples, and check boundary conditions like inclusive reach. Sorting inputs first is a habit worth drilling, since the examples give stations unsorted.