sheets[i] = [a, b] is the length and width of sheet i. A square of side k can be cut from a sheet if k ≤ a and k ≤ b.
Let best be the largest square side that can be cut from at least one sheet. Return how many sheets a square of side best can be cut from.sheets=[[6, 4], [9, 2], [4, 7], [3, 3]] → 2
The largest squares from the sheets are 4, 2, 4 and 3. The best side, 4, comes from two sheets.
sheets=[[10, 1], [2, 2]] → 1
A 10×1 strip only yields a 1×1 square, while the 2×2 sheet yields a 2×2 one.
sheets=[[6, 4], [9, 2], [4, 7], [3, 3]]
2
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.