Tap here to switch tabs
Problem
Submissions

Problem: Number Of Rectangles That Can Form The Largest Square

med
30 min
Try to solve the Number Of Rectangles That Can Form The Largest Square problem.

Statement

You are given an array of rectangles rectangles where rectangles[i] = [l_i, w_i] represents the iextthi^{ ext{th}} rectangle with a length of l_i and a width of w_i.

You can cut the iextthi^{ ext{th}} rectangle to form a square with a side length of at most kk, where k≤k \leq l_i and k≤k \leq w_i. The maximum side length of a square obtained from cutting this rectangle is min⁡(ext‘li‘,ext‘wi‘)\min( ext{`l_i`}, ext{`w_i`}).

Let maxLen be the side length of the largest square that can be formed from any of the given rectangles.

Return the total number of rectangles that can produce a square with a side length of maxLen.

Constraints:

  • 1≤1 \leq rectangles.length ≤1000\leq 1000

  • rectangles[i].length =2= 2

  • 1≤1 \leq l_i, w_i ≤109\leq 10^9

  • l_i ≠\neq w_i

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number Of Rectangles That Can Form The Largest Square

med
30 min
Try to solve the Number Of Rectangles That Can Form The Largest Square problem.

Statement

You are given an array of rectangles rectangles where rectangles[i] = [l_i, w_i] represents the iextthi^{ ext{th}} rectangle with a length of l_i and a width of w_i.

You can cut the iextthi^{ ext{th}} rectangle to form a square with a side length of at most kk, where k≤k \leq l_i and k≤k \leq w_i. The maximum side length of a square obtained from cutting this rectangle is min⁡(ext‘li‘,ext‘wi‘)\min( ext{`l_i`}, ext{`w_i`}).

Let maxLen be the side length of the largest square that can be formed from any of the given rectangles.

Return the total number of rectangles that can produce a square with a side length of maxLen.

Constraints:

  • 1≤1 \leq rectangles.length ≤1000\leq 1000

  • rectangles[i].length =2= 2

  • 1≤1 \leq l_i, w_i ≤109\leq 10^9

  • l_i ≠\neq w_i