Problem · Array
Rectangle Fit Queries
Learn this problemProblem statement
Process the rows of operations from left to right. Each row has one of two forms:
[0, a, b]: create and save a rectangle of sizea × b.[1, a, b]: determine whether every rectangle saved by earlier operations can fit inside a box of sizea × b.
Test each saved rectangle separately; the rectangles do not need to fit in the box at the same time. You may rotate a rectangle by 90 degrees.
Return one boolean for each query operation, in query order.
Function
solution(operations: int[][]) → boolean[]Examples
Example 1
operations = [[1,1,1]]return = [true]No rectangles have been saved, so every saved rectangle vacuously fits and the answer is true.
Example 2
operations = [[0,1,3],[0,4,2],[1,3,4],[1,3,2]]return = [true,false]Both saved rectangles fit the 3 × 4 box after choosing the appropriate orientation. The 4 × 2 rectangle cannot fit the later 3 × 2 box, so the answers are [true,false].
Constraints
1 ≤ operations.length ≤ 10^5operations[i].length = 3operations[i][0]is either0or1.1 ≤ operations[i][1] ≤ 10^51 ≤ operations[i][2] ≤ 10^5
Source note: Additional source evidence from a September 5, 2026 Capital One CodeSignal online assessment report.