Adjacent Order-Statistic Gap Distributions
Updated
Problem statement
For this exercise, the random draws are supplied as a matrix samples. Each row contains ten finite values in [0,1].
For every row:
- Sort a copy in ascending order.
- Compute
gapA = sorted[4] - sorted[3], the gap between the fourth and fifth order statistics. - Compute
gapB = sorted[5] - sorted[4], the gap between the fifth and sixth order statistics.
Return a double[][] with two rows. The first row contains every gapA; the second contains every gapB. Keep the input-row order, and do not change samples.
The two returned arrays are the two distributions of gaps. Drawing a chart and testing a hypothesis are follow-up discussion topics. They are not part of the output.
Function
adjacentGapDistributions(samples: double[][]) → double[][]Examples
Example 1
samples = [[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]]return = [[0.1],[0.1]]The sorted row is unchanged. Both adjacent gaps around the fifth order statistic equal 0.1.
Example 2
samples = [[0.9,0.1,0.4,0.8,0.2,0.7,0.3,0.6,0.0,0.5],[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]]return = [[0.1,0.0],[0.1,0.0]]The first row sorts to tenths from 0.0 through 0.9. The all-equal row has zero gaps.
Example 3
samples = [[0.0,0.0,0.0,0.0,0.25,0.75,1.0,1.0,1.0,1.0]]return = [[0.25],[0.5]]The fourth value is 0.0, the fifth is 0.25, and the sixth is 0.75.
Constraints
1 <= samples.length <= 100000.samples[i].length == 10.- Every value is finite and lies in
[0,1]. - Return gaps in input-row order.
- Answers within
10^-9of the correct values are accepted.
More Scale AI Phone Screen questions
- Four-Player Trick-Taking Card Game SimulationOA · PHONE SCREEN · Seen Aug 2026
- Task Processor: Dependencies and DeadlinesPHONE SCREEN · Seen Aug 2026
- Best Poker Category with a JokerPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026
- Free Time for Every Meeting RoomPHONE SCREEN · Seen Apr 2026
- Free Windows Between Busy IntervalsOA · PHONE SCREEN · Seen Apr 2026
- Order Queries by Shortest Processing TimePHONE SCREEN · Seen Apr 2026
- Party Time by Town and Quiet Gaps by CityPHONE SCREEN · Seen Jan 2026
- Party Windows and Dead Zone TimePHONE SCREEN · Seen Oct 2025
- Overlap Duration of Two Time IntervalsPHONE SCREEN · Seen Jun 2025
- Multi-Head Attention BlockPHONE SCREEN · Seen Mar 2025
Similar questions at other companies
- Optimal Central WarehouseGoogle · ONSITE INTERVIEWGoogle interview questions
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
- One-Nearest-Neighbor Classification with Manhattan DistanceOpenAI · PHONE SCREENOpenAI interview questions
- Map Black Cells to Covering 2x2 BlocksSquare · PHONE SCREEN
- Multiply Two MatricesAdobe · PHONE SCREENAdobe interview questions
- Matrix Multiplication With and Without NumPyNVIDIA · PHONE SCREENNVIDIA interview questions
- Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
- Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
- Bootstrap Mean and Confidence IntervalAmazon · PHONE SCREEN
- Find Missing and Duplicate IntegerInMobi · PHONE SCREENInMobi interview questions