python greedy solution
It is straightforward when S[i] is 0 or 2,\n When S[i] is 1, minus max(U, L) by one and set 1 to the corresponding position in res,\n Don\' t forget to check U 
* It is straightforward when S[i] is 0 or 2,\n* When S[i] is 1, minus max(U, L) by one and set 1 to the corresponding position in res,\n* Don\' t forget to check U and L are both 0 in the end.\n\n```\nclass Solution:\n    def reconstructMatrix(self, U: int, L: int, S: List[int]) -> List[List[int]]:\n        \n        res = [[0] * len(S) for _ in range(2)]\n        \n        for i in range(len(S)):\n            if S[i] == 2:\n                if U > 0 and L > 0:\n                    res[0][i] = res[1][i] = 1\n                    U -= 1\n                    L -= 1\n                else:\n                    return []\n            elif S[i] == 1:\n                if U > L:\n                    res[0][i] = 1\n                    U -= 1\n                elif L > 0:\n                    res[1][i] = 1\n                    L -= 1\n                else:\n                    return []\n        \n        return res if U == L == 0 else []
[]