FastPrepRectangle Fit Queries
Problem · Array

Rectangle Fit Queries

Learn this problem
MediumCapital One logoCapital OneNEW GRADINTERNOA

Problem 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 size a × b.
  • [1, a, b]: determine whether every rectangle saved by earlier operations can fit inside a box of size a × 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^5
  • operations[i].length = 3
  • operations[i][0] is either 0 or 1.
  • 1 ≤ operations[i][1] ≤ 10^5
  • 1 ≤ operations[i][2] ≤ 10^5

Source note: Additional source evidence from a September 5, 2026 Capital One CodeSignal online assessment report.

More Capital One problems

drafts saved locally
public boolean[] solution(int[][] operations) {
  // Write your code here
}
operations[[1,1,1]]
expected[true]
checking account