Simple solution with O(n) time complexity ...
IntuitionWe should take the smallest side from each rectangle and maximum from these numbers. And if there are many this kind of numbers we should count them ..
# Intuition
We should take the smallest side from each rectangle and maximum from these numbers. And if there are many this kind of numbers we should count them ...

# Approach
In for loop I took minimum side of each rectangle and checked weather it's the max and if it's the second max I incremented my count ...

# Complexity
- Time complexity:
O(n)

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

***C++*** solution : 

# Code
```cpp []
class Solution {
public:
    int countGoodRectangles(vector<vector<int>>& rectangles) {
       int max = std::min(rectangles[0][0], rectangles[0][1]);
        int count = 0;
        for (int i = 0; i < rectangles.size(); i++) {
            int currentMin = std::min(rectangles[i][0], rectangles[i][1]);
            if (max < currentMin) {
                max = currentMin;
                count = 1;
            } else if (max == currentMin) {
                count++;
            }
        }
        return count; 
    }
};
```

Here the ***Java*** solution : 
# Code
```Java []
class Solution {
    public int countGoodRectangles(int[][] rectangles) {
        int max = Math.min(rectangles[0][0],rectangles[0][1]);
        int count = 0;
        for(int i = 0; i<rectangles.length; i++){
            if(max < Math.min(rectangles[i][0],rectangles[i][1])){
                max = Math.min(rectangles[i][0],rectangles[i][1]);
                count = 1;
            }else if(max == Math.min(rectangles[i][0],rectangles[i][1])) count ++;
        }
        return count;
    }
}
```
['C++', 'Java']