Python 3 solution beats 92%
\n\n# Code\npy\nclass Solution:\n    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:\n        rowsum = [upper, lower]
![image.png](https://assets.leetcode.com/users/images/b3d9efe1-4b90-4ab5-a474-cf4c3cb3a2c2_1715431448.0712533.png)\n\n# Code\n```py\nclass Solution:\n    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:\n        rowsum = [upper, lower]        \n        if (twos := colsum.count(2)) > min(rowsum) or sum(rowsum) != sum(colsum):\n            return []        \n        grid = [[0 for c in colsum] for r in rowsum] \n        row, col = len(rowsum), len(colsum)     \n        for i in range(row):\n            rowsum[i] -= twos\n            for j in range(col):             \n                if colsum[j] == 2:\n                    grid[i][j] = 1\n                elif colsum[j] == 0 or rowsum[i] == 0:\n                    continue\n                else:\n                    grid[i][j] = 1\n                    rowsum[i] -= 1\n                    colsum[j] -= 1\n        return grid      \n```
['Python3']