Build Blocks and Obstacles on a Number Line
See the Image Source section at the very bottom of the page for the original problem statemetn :)
On an infinite number line, you need to build obstacles and check if blocks can fit without interference. There are two types of operations: [1, x] places an obstacle at coordinate x (guaranteed to be empty when placed), and [2, x, size] checks if a block of the given size can fit starting from position x. For example, with size = 2 and x = 0, it checks positions 0 and 1 for obstacles. If the space is clear, it returns 1; otherwise, it returns 0. Note that the [2, x, size] operation only checks feasibility without placing the block. Given an array of these operations, your task is to return a binary string representing the results of all [2, x, size] checks.
⸜(。˃ ᵕ ˂ )⸝♡ All the love to Charlotte baby 🧡
1Example 1
- [1, 2] - builds an obstacle at coordinate 2.
- [1, 5] - builds an obstacle at coordinate 5.
- [2, 3, 2] - checks and returns "1" as it is possible to build a block occupying coordinates 3 and 4.
- [2, 3, 3] - checks and returns "0" as it is not possible to build a block occupying coordinates 3, 4, and 5 because... (Will add more once find reliable reference 🐹 thank you for your understanding!
Constraints
Limits and guarantees your solution can rely on.
🍅🍅