[Most Simple] Swift solution - O(n) time and O(1) space


  • 0
    class Solution {
        func maxCount(_ m: Int, _ n: Int, _ ops: [[Int]]) -> Int {
            var minX = m
            var minY = n
            
            for op in ops {
                minX = min(op[0], minX)
                minY = min(op[1], minY)
            }
    
            return minX * minY
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.