Company: Visa fte

Difficulty: medium

Problem Statement

Block Building Operations Picture an infinite number line on which you can place obstacles and, at other times, ask whether a block of a given size could be fitted somewhere without overlapping any of them. Your program must support two kinds of operations: [1, x] - places an obstacle at coordinate x . Coordinate x is guaranteed to be free of any existing obstacle at the moment this operation is applied. [2, x, size] - tests whether a block centered at x and reaching size - 1 units to either side could be placed. For instance, with size = 3 and x = 0 , this checks every coordinate from -2 through 2 for obstacles. It produces "1" when none of those coordinates hold an obstacle, and "0" otherwise. Note that a type-2 operation only performs this check; it never actually places a block on the line. Given an array of operations mixing both operation types, return a binary string giving the outcome of every type-2 operation, listed in the order those operations occur. Input Format An array o

More Visa fte OA questionsInterview experiences