Build Blocks and Obstacles on a Number Line
Problem Overview
- Simulate two operations on an infinite number line: place an obstacle at x, or query if a block of size s fits from x without hitting obstacles.
- Input: array of operations [1,x] and [2,x,size]; obstacles are placed only on empty positions; queries do not modify the line.
- Output: a binary string (1/0) for each [2,x,size] feasibility check, in order.
- Domain: spatial fit checks and obstacle placement on a number line; typical coding interview problem.
- Source: Meta interviews; a practical interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
