Ctrl K

Biggest Square From the Sheets

Easy
You have rectangular plywood sheets: 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.
Example 1
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.

Example 2
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.

Constraints
  • 1 ≤ len(sheets) ≤ 1000
  • len(sheets[i]) = 2
  • 1 ≤ sheets[i][j] ≤ 10⁹
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPair With a Target Sum EasySqueeze Repeats Out of a Sorted Array EasyDrop the Unwanted Value EasySlot on a Sorted Shelf EasyAdd One to a Digit Array Easy
loading Python…
Input
sheets=[[6, 4], [9, 2], [4, 7], [3, 3]]
Expected
2

Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.