Reported April 2024
Skydiosliding window

Rolling Five-Second Flight-Distance Alerts

Reported by candidates from Skydio's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Skydio OA. Under 2s to a working solution.
Founder's read

Five seconds of drone telemetry, one threshold, and a list of indices to return. That's the Skydio OA reported in April 2024, and it looks like geometry until you see it's a rolling sum in disguise. Compute each segment's Euclidean length once, then slide a window over them. The statement says five seconds but the window holds at most four segments, which is the detail that trips people up. Example 1 spells it out: indices 4 and 5 total 1.2 meters. If you blank on the window math during the live OA, StealthCoder runs invisibly as a safety net. Read the trick below first.

The problem

A drone reports one planar coordinate at each integer second. For every report index i > 0, compute the path length traveled during the most recent five seconds: sum the adjacent-segment lengths whose ending indices are from max(1, i - 4) through i.
Return every zero-based index where that rolling distance is at least threshold.

Function
rollingDistanceAlerts(coordinates: double[][], threshold: double) → int[]

Examples
Example 1
coordinates = [[0.0,0.0],[0.3,0.0],[0.6,0.0],[0.9,0.0],[1.2,0.0],[1.5,0.0]]
threshold = 1.0
return = [4,5]
At indices 4 and 5, the most recent four segments total 1.2 meters.
Example 2
coordinates = [[0.0,0.0],[0.1,0.0],[0.2,0.0]]
threshold = 1.0
return = []
No rolling window reaches one meter.

Constraints
1 <= coordinates.length <= 100000.
Every coordinate has exactly two finite values.
0 < threshold <= 1000000000.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is a sliding window over prefix sums. Build an array of segment lengths, where seg[j] is the distance from point j-1 to point j, using sqrt(dx*dx + dy*dy) or Math.hypot. For index i, sum seg[max(1, i-4)] through seg[i]. Keep a running sum: add seg[i], and subtract seg[i-5] once i >= 5. Then compare against the threshold. Index 0 never alerts because it has no segment. The pitfall is off-by-one. The window covers at most four segments, not five, so check your subtraction index against Example 1. The second pitfall is floating-point drift. A running sum can accumulate error over 100000 points, so a prefix-sum array or a careful comparison is safer near the threshold. Single pass, O(n) time. If the window logic slips under pressure, StealthCoder is the hedge on the live OA.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Rolling Five-Second Flight-Distance Alerts 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. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Skydio's OA.

Skydio reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Rolling Five-Second Flight-Distance Alerts FAQ

What's the trick in the Skydio rolling distance problem?+

Precompute each segment length once, then keep a sliding window sum over the last four segments. Add the new segment, drop the one that fell out, compare to the threshold. It's O(n) and avoids recomputing five distances at every index.

Why does the window hold four segments and not five?+

Five seconds means five reports, but five reports only give four gaps between them. Segments are indexed by their ending point, so i-4 through i would be five, but index 0 has no segment. Early on, the window is clipped by max(1, i-4). Verify against Example 1.

Should I worry about floating-point precision?+

Slightly. A running add/subtract sum over 100000 points can drift. A prefix-sum array, where window = pre[i] - pre[lo-1], keeps error smaller. The threshold comparison is at least, so use >= and don't add a fudge epsilon unless the statement asks.

Will index 0 ever be in the output?+

No. The rule is defined for i > 0, and index 0 has no segment ending there. Start your loop at 1. Also handle a single-coordinate input, which should return an empty array.

How do I prepare for this in 48 hours?+

Write the sliding window sum on a plain array until the add-and-drop step is automatic. Then add the distance step with Math.hypot and test both examples by hand. Pay attention to the window boundary at i = 1 through 4, because that's where bugs hide.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Skydio.

OA at Skydio?
Invisible during screen share
Get it