Python solution beats 97% with comments
class Solution:\n\n    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:\n        if sum(colsum) != upper+lower:\n     
class Solution:\n\n    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:\n        if sum(colsum) != upper+lower:\n            return []\n        ans = [[0]*len(colsum) for _ in range(2)]\n        for i in range(len(colsum)): #if colsum is equal to 2, we have no choice but put 1 in both rows\n            if colsum[i] == 2:\n                ans[0][i] = 1\n                ans[1][i] = 1\n                upper-=1\n                lower-=1\n        \n        for i in range(len(colsum)):\n            if colsum[i] == 1: \n                if upper>0: #try to put into the upper row first \n                    ans[0][i] = 1\n                    upper-=1\n                elif lower > 0: # and then the lower row\n                    ans[1][i] = 1\n                    lower -= 1\n                if upper <0 or lower <0: # if any negative value found, return \n                    return []\n        return ans
['Python']