Swift
\n\nclass Solution {\n    func minRectanglesToCoverPoints(_ points: [[Int]], _ w: Int) -> Int {\n        // Sort points by their x-values\n        let sortedPoi
\n```\nclass Solution {\n    func minRectanglesToCoverPoints(_ points: [[Int]], _ w: Int) -> Int {\n        // Sort points by their x-values\n        let sortedPoints = points.sorted { $0[0] < $1[0] }\n        \n        var count = 0\n        var i = 0\n        let n = sortedPoints.count\n        \n        // Use a greedy approach to cover points\n        while i < n {\n            count += 1\n            // The starting x value of the current rectangle\n            let startX = sortedPoints[i][0]\n            // Move i to the first point which is out of the current rectangle\'s range\n            while i < n && sortedPoints[i][0] <= startX + w {\n                i += 1\n            }\n        }\n        \n        return count\n    }\n}\n```
['Swift']