Simple Java Greedy Approach Beats 95.67%....Hope it helps
O(n)# Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n-
$$O(n)$$# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\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```\n\nclass Solution {\n    public List<List<Integer>> reconstructMatrix(int upper, int lower, int[] colSum) {\n        int [] rowSum = {upper ,lower};\n        int row = 2;\n        int col = colSum.length;\n        Integer[][] ans =new Integer[2][col];\n        List<List<Integer>> aaa = new ArrayList<>();\n        \n        for(int j = 0 ; j<col ; j++){\n            \n            if(colSum[j] == 2){\n                ans[0][j] = 1;\n                ans[1][j] = 1;\n                rowSum[0]-=1;\n                rowSum[1]-=1;\n            } if (colSum[j] == 0){\n                ans[0][j] = 0;\n                ans[1][j] = 0;\n            }if(colSum[j] ==1){\n                if(rowSum[0] < rowSum[1]){\n                    ans[0][j] = 0;\n                    ans[1][j] = 1;\n                    rowSum[1]-=1;\n                }else{\n                    ans[0][j] = 1;\n                    ans[1][j] = 0;\n                    rowSum[0] -=1;\n                }\n            }\n\n            if(rowSum[0] < 0 || rowSum[1] <0)return aaa;\n        }\n\n         if(rowSum[0] != 0 || rowSum[1] != 0)return aaa;\n         \n        \n        aaa.add(Arrays.asList(ans[0]));\n        aaa.add(Arrays.asList(ans[1]));\n\n        return aaa;\n    }\n    \n}\n```\n
['Greedy', 'Java']