1253. Reconstruct a 2-Row Binary Matrix
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:
        n = len(colsum)
        result = [[0] * n for _ in range(2)]
        
        for i in range(n):
            if colsum[i] == 2:
                if upper > 0 and lower > 0:
                    result[0][i] = result[1][i] = 1
                    upper -= 1
                    lower -= 1
                else:
                    return []
            elif colsum[i] == 1:
                if upper > lower:
                    result[0][i] = 1
                    upper -= 1
                elif lower >= upper:
                    result[1][i] = 1
                    lower -= 1
                else:
                    return []
        
        if upper == 0 and lower == 0:
            return result
        return []

```
['Python3']