Centered Block Placement Queries
Updated
Problem statement
Given a list of queries on an infinite number line of integer coordinates that starts with no obstacles, process the queries in order and return a binary string with one character for each check query.
[1, x]places an obstacle at coordinatex. Coordinatexis guaranteed to be empty.[2, x, size]checks a block centered atx. The block covers every integer coordinate fromx - size + 1tox + size - 1, inclusive. Append'1'if none of those coordinates has an obstacle, and'0'otherwise. A check does not place the block.
Function
processBlockQueries(queries: int[][]) → StringExamples
Example 1
queries = [[2,0,3],[1,2],[2,0,3],[2,-3,2]]return = "101"The first check covers -2 through 2, which is empty, so it gives '1'. After an obstacle is placed at 2, the same check gives '0'. The last check covers -4 through -2, which is empty, so it gives '1'.
Example 2
queries = [[1,5],[2,5,1],[2,4,1],[2,3,3]]return = "010"A block of size 1 covers only its center. The check at 5 hits the obstacle, and the check at 4 is empty. The last check covers 1 through 5, and its right end is the obstacle at 5.
Example 3
queries = [[1,-1000000000],[2,999999999,1000000000],[2,0,1000000000],[2,-1,1000000000]]return = "110"The first check covers 0 through 1999999998. The second covers -999999999 through 999999999, which stops one short of the obstacle. The third covers -1000000000 through 999999998 and includes the obstacle.
Constraints
1 <= queries.length <= 10^5- Each insertion query has
2integers and each check query has3integers. -10^9 <= x <= 10^91 <= size <= 10^9- Inserted obstacle coordinates are distinct.
More Susquehanna International Group (SIG) Online Assessment questions
- Catch Fish with Reusable BaitsOA · Seen Nov 2026
- Bold Play to Reach a GoalOA · Seen Nov 2026
- Cats, Truth and Who Has MoreOA · Seen Nov 2026
- Counting Cows by Their LegsOA · Seen Nov 2026
- Enough Muffins for the LineOA · Seen Nov 2026
- Expected Consecutive Pairs Among Chosen NumbersOA · Seen Nov 2026
- Four-by-Four Boundary GridOA · Seen Nov 2026
- Frog Paths Without Long RunsOA · Seen Nov 2026
- Higher Roll, or Lose the SumOA · Seen Nov 2026
- Is a Popular Story Fake?OA · Seen Nov 2026
Similar questions at other companies
- Rolling MetricsAkuna Capital · OAAkuna Capital interview questions
- Centered Block Placement QueriesRoblox · OARoblox interview questions
- Maximum Profit from an Increasing Price TripletOdoo · OAOdoo interview questions
- Longest Subarray with Sum at Most KGoogle · OAGoogle interview questions
- Maximum Laptop Rating in a Price RangePostman · OAPostman interview questions
- Employee Ratings Management SystemAmazon · PHONE SCREEN
- Running Medians and PercentilesStackAdapt · PHONE SCREENStackAdapt interview questions
- Range ModuleWalmart · PHONE SCREENWalmart interview questions
- Order Sequence Prefix Counts and QuantitiesHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
- Count Later Lower ReadingsRippling · ONSITE INTERVIEWRippling interview questions