Python Greedy very easy with comments
\nclass Solution:\n    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:\n        result, sums = [[0 for i in range(len
```\nclass Solution:\n    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:\n        result, sums = [[0 for i in range(len(colsum))] for j in range(2)], [upper, lower]\n\t\t# no solution possible\n        if sum(sums) != sum(colsum):\n            return []\n        for i, val in enumerate(colsum):\n            if not sums[0] and not sums[1]:\n                break\n\t\t\t# if it is a 0 or a 2 then we add 0 or 1 to both the cells\n            if val == 2 or val == 0:\n                result[0][i], result[1][i] = val // 2, val // 2\n                for i in range(2):\n                    sums[i] -= val // 2\n            else:\n\t\t\t    #  Add 1 to the row where more 1s are to be  assigned\n                index = 0 if sums[0] > sums[1] else 1\n                result[index][i] = 1\n                sums[index] -= 1\n\t\t# The solution found is invalid meaning no solution is possible\n        if sum(result[0]) != upper or sum(result[1]) != lower:\n            return []\n        return result\n```
[]