Kotlin solution (beats 100% of users in time and space complexity)
Complexity
Time complexity: O(n)

Space complexity: O(n)
Code
# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```kotlin []
class Solution {
    fun countGoodRectangles(rectangles: Array<IntArray>): Int {
        val squareLengths = IntArray(rectangles.size)
        var mx = 0
        for (i in squareLengths.indices) {
            val mn = rectangles[i].min()
            squareLengths[i] = mn
            if (mn > mx) mx = mn
        }
        return squareLengths.count {it == mx}
    }
}
```
['Kotlin']