Java O(N)
Intuition\n Describe your first thoughts on how to solve this problem. \nOne pass \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexi
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nOne pass \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public List<List<Integer>> reconstructMatrix(int upper, int lower, int[] colsum) {\n        List<Integer> lUp = new ArrayList<>(), lLow = new ArrayList<>();\n        for (int csum : colsum) {\n            if (csum == 2) {\n                lUp.add(1);\n                lLow.add(1);\n                upper--;\n                lower--;\n            } else if (csum == 0) {\n                lUp.add(0);\n                lLow.add(0);\n            } else {\n                if (upper >= lower) {\n                    lUp.add(1);\n                    lLow.add(0);\n                    upper--;\n                } else {\n                    lUp.add(0);\n                    lLow.add(1);\n                    lower--;\n                }\n            }\n        }\n        if (upper != 0 || lower != 0)\n            return new ArrayList(new ArrayList());\n        return new ArrayList(List.of(lUp, lLow));\n    }\n}\n```
['Java']