26 ms Beats 100.00%
Complexity
Time complexity:
O(N)
Code
# Complexity
- Time complexity:
O(N)

# Code
```python []
class Solution(object):
    def reconstructMatrix(self, upper, lower, colsum):
        """
        :type upper: int
        :type lower: int
        :type colsum: List[int]
        :rtype: List[List[int]]
        """
        if upper+lower != sum(colsum):
            return []
        xsum = 0
        ysum = 0
        ln = 2
        ans = [[0] * len(colsum) for _ in range(2)]
        for x in range(len(colsum)):
            if colsum[x] == 2:
                ans[0][x] = 1
                ans[1][x] = 1
                xsum += 1
                ysum +=1
        
        for x,y in enumerate(colsum):
            if y == 1:
                if xsum != upper:
                    ans[0][x] = 1
                    xsum +=1
                else:
                    ans[1][x] = 1
                    ysum += 1

        if xsum== upper and ysum == lower:
            return ans
        
        return []
```
['Python']