Search
⌘K

Leetcode 2001. Number of Pairs of Interchangeable Rectangles

Count how many index pairs of rectangles share the same width:height ratio. Normalize each (w,h) to its reduced form (e.g., divide by gcd) and use a hash map to tally frequencies, then sum frequency choose 2 (n up to 1e5 so avoid O(n^2) or floating-point comparisons).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.