Number-Line Obstacles and Block Checks
Updated
Problem statement
Process operations on an infinite integer number line:
[1, x]permanently inserts an obstacle at x.[2, x, size]checks whether every coordinate from x through x + size - 1 is obstacle-free, without changing state.
Append 1 for a successful check and 0 otherwise. Return all check results as one binary string.
Function
processObstacleQueries(queries: int[][]) → StringExamples
Example 1
queries = [[1,2],[2,0,2],[2,0,3],[1,5],[2,3,3]]return = "100"[0,1] is free, [0,2] contains obstacle 2, and [3,5] contains obstacle 5.
Example 2
queries = [[2,-2,3]]return = "1"No obstacles exist yet.
Constraints
1 <= queries.length <= 100000- Inserted coordinates are distinct.
- The total size across check queries is at most 1000000.
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Branch with the Most FilesCapital One · OACapital One interview questions
- Per-User Sliding-Window Rate LimiterPayPal · OAPayPal interview questions
- Count Server ReplacementsAkuna Capital · OAAkuna Capital interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
- Student and Course EnrollmentWells Fargo · OAWells Fargo interview questions
- Network Endpoint or Cycle BoundaryOpenAI · OA · PHONE SCREENOpenAI interview questions
- Assign Server Numbers by TypeOura · OA
- Filter Transaction Logs and Calculate Reliability MetricsStripe · OAStripe interview questions
- Calculate Net ProfitJP Morgan Chase · OAJP Morgan Chase interview questions