Python 3 | Greedy | Explanations
Explanation\n- Ultimately, we have to fill out 2 row and use exactly upper+lower values, so simply take the greedy apporach\n\t- if upper + lower != sum(colsum)
### Explanation\n- Ultimately, we have to fill out 2 row and use exactly `upper+lower` values, so simply take the greedy apporach\n\t- if `upper + lower != sum(colsum)`, `return []`\n\t- when `colsum[i] == 2` and `upper` and `lower` are available, place both row and decrement variables\n\t- when `colsum[i] == 1` take whoever is larger and place `1` on cooresponding row\n\t- when `colsum[i] == 0` ignore and `continue`\n\t- else `return []`\n- `u`: first row\n- `d`: second row\n### Implementation\n```\nclass Solution:\n    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:\n        s, n = sum(colsum), len(colsum)\n        if upper + lower != s: return []\n        u, d = [0] * n, [0] * n\n        for i in range(n):\n            if colsum[i] == 2 and upper > 0 and lower > 0:\n                u[i] = d[i] = 1\n                upper, lower = upper-1, lower-1\n            elif colsum[i] == 1:    \n                if upper > 0 and upper >= lower:\n                    u[i], upper = 1, upper-1\n                elif lower > 0 and lower > upper:\n                    d[i], lower = 1, lower-1\n                else: return []    \n            elif not colsum[i]: continue\n            else: return []\n        return [u, d] \n```
['Greedy', 'Python', 'Python3']