Rectangle Fit Queries
Updated
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 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
operationscontains at least one row.operations[i].length = 3.operations[i][0]is either0or1.operations[i][1]andoperations[i][2]are positive integers.
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- HTTP Request RedirectionAmazon · OA
- Streamed Planar Item TripletsGoogle · ONSITE INTERVIEWGoogle interview questions
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Request Routing SystemStripe · OAStripe interview questions
- Count Overlapping Square PairsRamp · OARamp interview questions
- Capping Portfolio WeightsCapstone Investment Advisors · OA
- Repeated Mirror XORMathWorks · OAMathWorks interview questions
- Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
- Stabilize Student Test ScoresVirtu Financial · OAVirtu Financial interview questions
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW