diff --git a/cpp/2001-number-of-pairs-of-interchangeable-rectangles.cpp b/cpp/2001-number-of-pairs-of-interchangeable-rectangles.cpp new file mode 100644 index 000000000..7bc66d5c9 --- /dev/null +++ b/cpp/2001-number-of-pairs-of-interchangeable-rectangles.cpp @@ -0,0 +1,38 @@ +/* + Approach: + Keep the track of the ratios in a hash map + + Time complexity : O(n) + Space complexity: O(n) + + n is number of rectangles +*/ + +class Solution { +public: + long long interchangeableRectangles(vector>& rectangles) { + + map hash; + long double ratio; + + long long answer=0; + + for(int i=0;i