python simple and fast O(n)
\nclass Solution:\n    def reconstructMatrix(self, upper, lower, colsum):\n        if upper + lower != sum(colsum):\n            return []\n        N = len(cols
```\nclass Solution:\n    def reconstructMatrix(self, upper, lower, colsum):\n        if upper + lower != sum(colsum):\n            return []\n        N = len(colsum)\n        \n        num_two = colsum.count(2)\n        if num_two > lower or num_two > upper:\n            return []\n        \n        res = [[0 for _ in range(N)] for _ in range(2)]\n        \n        for idx in range(N):\n            if colsum[idx] == 0:\n                continue\n            elif colsum[idx] == 2:\n                res[0][idx] = res[1][idx] = 1\n                upper -= 1\n                lower -= 1\n            elif upper >= lower:\n                res[0][idx] = 1\n                upper -= 1\n            else :\n                res[1][idx] = 1\n                lower -= 1\n\n        return res\n```
['Python']