Swift solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n$$O(N)$$\n\n- Space complexity:\n$$O(N)$$\n\n# Code\n```swift []\nclass Solution {\n    func reconstructMatrix(_ upper: Int, _ lower: Int, _ colsum: [Int]) -> [[Int]] {\n        // Time: O(N)\n        // Space: O(N)\n        var res = Array(repeating: Array(repeating: 0, count: colsum.count), count: 2)\n        var upper = upper, lower = lower\n        for i in 0..<colsum.count {\n            if colsum[i] == 2 {\n                res[0][i] = 1\n                res[1][i] = 1\n                upper -= 1\n                lower -= 1\n            } else if colsum[i] == 1 {\n                if upper > lower {\n                    res[0][i] = 1\n                    upper -= 1\n                } else {\n                    res[1][i] = 1\n                    lower -= 1\n                }\n            }\n        }\n        return (0 == upper && 0 == lower) ? res : []\n    }\n}\n```
['Swift']