Forward Block Placement Queries
Updated
Problem statement
Process operations on a nonnegative integer line. Initially, no position contains an obstacle.
[1, x]places an obstacle at positionx. Placing an obstacle at an occupied position has no additional effect.[2, start, length]asks whether every integer position in the inclusive interval[start, start + length - 1]is empty. Append1when the block fits and0otherwise. A query does not place a block.
Return the appended bits as one string in query order.
Function
forwardBlockPlacementQueries(operations: int[][]) → StringExamples
Example 1
operations = [[1,2],[1,5],[2,3,2],[2,3,3],[2,1,1],[2,1,2]]return = "1010"Positions 3 through 4 are empty, but 3 through 5 contains an obstacle. Position 1 is empty, while 1 through 2 contains an obstacle.
Example 2
operations = [[2,0,1],[1,0],[2,0,1],[1,0],[2,1,3]]return = "101"The first query succeeds. After position 0 is occupied, the second fails; repeating the build is idempotent, and positions 1 through 3 remain empty.
Constraints
1 <= operations.length <= 10^5.- Each operation is either
[1, x]or[2, start, length]. 0 <= x, start <= 10^9.1 <= length <= 10^9.- Interval endpoints fit in signed 64-bit integers.
More Capital One Online Assessment questions
- Rank Football TeamsOA · Seen Oct 2026
- Count Subarrays Matching a Comparison PatternOA · Seen Oct 2026
- Arithmetic Triplets After QueriesOA · Seen Oct 2026
- Branch with the Most FilesOA · Seen Oct 2026
- Count One-Swap Number PairsOA · Seen Oct 2026
- Distinct Values on Maximum-Sum FramesOA · Seen Oct 2026
- Earliest Meeting Time for All EmployeesOA · Seen Oct 2026
- Earn the Most 🐝OA · Seen Oct 2026
- Sort Adjacent PairsOA · Seen Oct 2026
- Bouncing Diagonal WeightsOA · Seen Oct 2026
Similar questions at other companies
- Index of the Maximum After Left RotationsChubb · OAChubb interview questions
- Rolling MetricsAkuna Capital · OAAkuna Capital interview questions
- Souvenir Shop PurchasesAmazon · OA
- The OraclesRubrik · OARubrik interview questions
- Online Meeting Scheduler with Fixed RoomsUber · ONSITE INTERVIEWUber interview questions
- Detect a Silent SensorConfluent · ONSITE INTERVIEWConfluent interview questions
- Sorted Insertion SnapshotsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Finish Ordered CPU Tasks with the Fewest CPUsGoogle · PHONE SCREENGoogle interview questions
- Capping Portfolio WeightsCapstone Investment Advisors · OA
- Subscription and Usage-Based Billing CalculatorStripe · OAStripe interview questions