Sorted Insertion Snapshots
Updated
Problem statement
Process the integers in values from left to right while maintaining one sorted vector-like sequence. Insert each new value at its lower-bound position: immediately before the first current value that is greater than or equal to it.
Return one snapshot after every insertion. Snapshot i contains the complete sorted sequence after inserting values[i]. Insertion by move and insertion by copy have the same observable value behavior in this exercise.
Function
sortedInsertionSnapshots(values: int[]) → int[][]Examples
Example 1
values = [3,1,2]return = [[3],[1,3],[1,2,3]]Each row captures the full ordered sequence after that insertion.
Example 2
values = [2,2,-1]return = [[2],[2,2],[-1,2,2]]Equal values remain adjacent and the final negative value moves to the front.
Example 3
values = [1,4,9]return = [[1],[1,4],[1,4,9]]Every new value belongs at the end.
Constraints
1 <= values.length <= 1000.-10^9 <= values[i] <= 10^9.- The total number of returned integers is at most
500500.
More Squarepoint Capital Phone Screen questions
- Lazy Filter over a GeneratorPHONE SCREEN · Seen Nov 2026
- Moving Average of a Data StreamPHONE SCREEN · Seen Nov 2026
- Newton Square Root to a Guaranteed TolerancePHONE SCREEN · Seen Nov 2026
- Probability of Consecutive HeadsPHONE SCREEN · Seen Nov 2026
- Three Points in a Semicircle: Monte Carlo EstimatePHONE SCREEN · Seen Nov 2026
- Combine Two Index SequencesPHONE SCREEN · Seen Aug 2026
- Parse, Normalize, and Combine PolynomialsPHONE SCREEN · Seen Aug 2026
- Strong and Weak Reference LifecyclePHONE SCREEN · Seen Aug 2026
- Target Sum Across Two Sorted ArraysPHONE SCREEN · Seen Aug 2026
- Classify Heap Addresses from a Memory SnapshotPHONE SCREEN · Seen Nov 2025
Similar questions at other companies
- Finish Ordered CPU Tasks with the Fewest CPUsGoogle · PHONE SCREENGoogle interview questions
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Online Meeting Scheduler with Fixed RoomsUber · ONSITE INTERVIEWUber interview questions
- Index of the Maximum After Left RotationsChubb · OAChubb interview questions
- Rolling MetricsAkuna Capital · OAAkuna Capital interview questions
- Forward Block Placement QueriesCapital One · OACapital One interview questions
- Detect a Silent SensorConfluent · ONSITE INTERVIEWConfluent interview questions
- Souvenir Shop PurchasesAmazon · OA
- The OraclesRubrik · OARubrik interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions