JAVA EASY SOLUTION O(N) SINGLE PASS
\nclass Solution {\n     \n    public List<List<Integer>> reconstructMatrix(int upper, int lower, int[] colsum) {\n       List<List<Integer>>  list=new ArrayLis
```\nclass Solution {\n     \n    public List<List<Integer>> reconstructMatrix(int upper, int lower, int[] colsum) {\n       List<List<Integer>>  list=new ArrayList<>();\n       ArrayList<Integer> up=new ArrayList<>();\n        ArrayList<Integer> down=new ArrayList<>();\n        \n        \n        \n        for(int i=0;i<colsum.length;i++){\n            if(colsum[i]==2){\n                up.add(1);\n                down.add(1);\n                upper--;\n                lower--;\n            }\n            else if(colsum[i]==0){\n                up.add(0);\n                down.add(0);\n                \n            }\n            else{\n                if(upper>=lower){\n                    up.add(1);\n                    down.add(0);\n                    upper--;\n                    \n                }\n                else{\n                    down.add(1);\n                    up.add(0);\n                    lower--;\n                }\n            }\n        }\n        if(upper==0&&lower==0){\n            list.add(up);\n            list.add(down);\n        }\n        \n        return list;\n    }\n    \n   \n    \n}\n```
[]