Algorithm · Capital One · Medium
Picture a straight strip of land made up of n positions, numbered 1 through n, all of which start out empty. You will receive q operations and must apply them one after another. Each operation has one of two forms: [1, x] constructs a single unit block on position x. Position x is guaranteed to be empty before this operation. [2, x, len] asks whether the range [x, x + len - 1] is completely usable, meaning every position in it lies inside 1..n and none of them holds a block.…