Tap here to switch tabs
Problem
Submissions

Problem: Number of Pairs of Interchangeable Rectangles

Try to solve the Number of Pairs of Interchangeable Rectangles problem.

Statement

You are given an array rectangles containing nn rectangles, where rectangles[i] = [extwidthi,extheighti][ ext{width}_i, ext{height}_i] represents the dimensions of the iextthi^{ ext{th}} rectangle.

Two rectangles ii and jj (where i<ji < j) are considered interchangeable if they have the same width to height ratio, defined as extwidthiextheighti=extwidthjextheightj\frac{ ext{width}_i}{ ext{height}_i} = \frac{ ext{width}_j}{ ext{height}_j}.

Return the total number of interchangeable pairs of rectangles in rectangles.

Constraints:

  • n=n = rectangles.length

  • 1≤n≤1051 \leq n \leq 10^5

  • rectangles[i].length =2= 2

  • 1≤extwidthi,extheighti≤1051 \leq ext{width}_i, ext{height}_i \leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Pairs of Interchangeable Rectangles

Try to solve the Number of Pairs of Interchangeable Rectangles problem.

Statement

You are given an array rectangles containing nn rectangles, where rectangles[i] = [extwidthi,extheighti][ ext{width}_i, ext{height}_i] represents the dimensions of the iextthi^{ ext{th}} rectangle.

Two rectangles ii and jj (where i<ji < j) are considered interchangeable if they have the same width to height ratio, defined as extwidthiextheighti=extwidthjextheightj\frac{ ext{width}_i}{ ext{height}_i} = \frac{ ext{width}_j}{ ext{height}_j}.

Return the total number of interchangeable pairs of rectangles in rectangles.

Constraints:

  • n=n = rectangles.length

  • 1≤n≤1051 \leq n \leq 10^5

  • rectangles[i].length =2= 2

  • 1≤extwidthi,extheighti≤1051 \leq ext{width}_i, ext{height}_i \leq 10^5