Description
Solutions
Build Blocks and Obstacles
š¤ INTERNšRELATED PROBLEMS
Note š³ See source image below for the original statement :)
Imagine youāre working with an endless number line and want to place obstacles and check if you can build blocks on it. You have two types of tasks: one allows you to place an obstacle at a specific point, ensuring that spot is free when you do so. The other lets you check if it's possible to build a block of a certain size ending just before a given point, making sure there are no obstacles in the way. Your goal is to process a list of these tasks and return a string of "1"s and "0"s, where each "1" means you can build the block, and each "0" means you can't.
š§” Shoutout for Charlotte baby š§”
Example 1:
Input: operations = [[1, 2], [1, 5], [2, 5, 2], [2, 6, 3], [2, 2, 1], [2, 3, 2]]
Output: "1010"
Explanation:Let's walk through each operation step by step: [1, 2]: An obstacle is placed at coordinate 2. [1, 5]: Another obstacle is placed at coordinate 5. [2, 5, 2]: We check if we can build a block covering coordinates 3 and 4. Since there are no obstacles, the answer is "1". [2, 6, 3]: We check if we can build a block covering coordinates 3, 4, and 5. But since thereās an obstacle at coordinate 5, the answer is "0". [2, 2, 1]: We check if we can build a block at coordinate 1. Since there are no obstacles, the answer is "1". [2, 3, 2]: Finally, we check if we can build a block covering coordinates 1 and 2. Since thereās an obstacle at coordinate 2, the answer is "0".
Constraints:
All coordinates within operations are within the following interval [-109, 109
The size from the second type of operation are positive integers which would not exceed 109
1 <= operations.length <= 105
A binary string representing the outputs for all [2, x, size] operations



Related Problems
Testcase
Result
Case 1
input:
output: