Tap here to switch tabs
Problem
Submissions

Problem: Number Of Rectangles That Can Form The Largest Square

Number Of Rectangles That Can Form The Largest Square gives an array of rectangle dimensions. Count how many can produce a square whose side is the greatest possible side length.

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 ithi^{ {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⁡(‘li‘,‘wi‘)\min( {`l_i`}, {`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

Number Of Rectangles That Can Form The Largest Square gives an array of rectangle dimensions. Count how many can produce a square whose side is the greatest possible side length.

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 ithi^{ {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⁡(‘li‘,‘wi‘)\min( {`l_i`}, {`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