Cumulative Flight-Distance Alerts
Updated
Problem statement
A drone reports planar coordinates in travel order. Starting with the first report, accumulate the Euclidean length of every traveled segment. Whenever the accumulated distance is at least threshold, emit the current zero-based coordinate index and reset the accumulator to zero.
Return all emitted indices in increasing order. Distance left after the final report does not emit an alert.
Function
distanceAlerts(coordinates: double[][], threshold: double) → int[]Examples
Example 1
coordinates = [[0.0,0.0],[0.5,0.0],[1.0,0.0],[1.1,0.3],[2.0,1.0]]threshold = 1.0return = [2,4]The first two segments total one meter. After reset, the final two segments exceed one meter.
Example 2
coordinates = [[0.0,0.0],[0.3,0.4]]threshold = 1.0return = []The path length is only 0.5 meters.
Constraints
1 <= coordinates.length <= 100000.- Every coordinate has exactly two finite values.
0 < threshold <= 1000000000.
More Skydio interview questions
Similar questions at other companies
- Logistic Regression with Gradient DescentYahoo · PHONE SCREENYahoo interview questions
- Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
- Adaptive Calibration ErrorOpenAI · PHONE SCREENOpenAI interview questions
- Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Reachable Transfer PositionsCitadel · PHONE SCREENCitadel interview questions
- Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
- Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
- Filter Paginated Medical RecordsNVIDIA · PHONE SCREENNVIDIA interview questions
- Minimum Operations to Make Every Array Element OneOtter.ai · PHONE SCREENOtter.ai interview questions
- Evenly Schedule Vehicle InspectionsAmazon · PHONE SCREEN