Java Simple greedy with pitfalls
greedy is simple, \n1, if colsum is 0, or 2, aka colsum % 2 == 0, assign colsum / 2 to upper and lower row each;\n2, Otherwise, colsum is 1, based on diff = upp
greedy is simple, \n1, if colsum is 0, or 2, aka colsum % 2 == 0, assign colsum / 2 to upper and lower row each;\n2, Otherwise, colsum is 1, based on diff = upper - lower, to assign 1 and 0, remember to update diff\n3, check if diff != 0 || upper + lower != sum, invalid, return empty list;\n\n```\n    public List<List<Integer>> reconstructMatrix(int upper, int lower, int[] colsum) {\n        List<List<Integer>> res = new ArrayList<>();\n        List<Integer> up = new ArrayList<>(), lo = new ArrayList<>();\n        int diff = upper - lower, sum = 0;\n        for (int i : colsum) {\n            sum += i;\n            if (i % 2 == 0) {  // colsum 0, or 2\n                up.add(i / 2);\n                lo.add(i / 2);\n            } else {  //colsum is 1\n                if (diff >= 0) {\n                    up.add(1);\n                    lo.add(0);\n                    diff--;\n                } else {\n                    up.add(0);\n                    lo.add(1);\n                    diff++;\n                }\n            }\n        }\n        if (diff != 0 || upper + lower != sum) return res;\n        res.add(up);\n        res.add(lo);\n        return res;\n    }\n```
[]