simple O(n)  using HashMap
\nvar countGoodRectangles = function (rectangles) {\n  let map = new Map(),max=0;\n  rectangles.forEach(el => {\n    max=Math.max(max,Math.min(el[0], el[1]));\n
```\nvar countGoodRectangles = function (rectangles) {\n  let map = new Map(),max=0;\n  rectangles.forEach(el => {\n    max=Math.max(max,Math.min(el[0], el[1]));\n    map.set(Math.min(el[0], el[1]), map.get(Math.min(el[0], el[1])) + 1 || 1);\n  });\n  return map.get(max);\n};\n```
['JavaScript']