C++/Java 5 lines
Intuition\nIf the column sum is 2 or 0, the choice is obvius.\n\nIf it\'s 1, we set the upper bit if upper is larger than lower, and lower bit otherwise.\n\nC++
#### Intuition\nIf the column sum is `2` or `0`, the choice is obvius.\n\nIf it\'s `1`, we set the upper bit if `upper` is larger than `lower`, and lower bit otherwise.\n\n**C++**\n> See Java version below for less compacted version :)\n```\nvector<vector<int>> reconstructMatrix(int u, int l, vector<int>& cs) {\n    vector<vector<int>> res(2, vector<int>(cs.size()));\n    for (auto i = 0; i < cs.size(); u -= res[0][i], l -= res[1][i++]) {\n        res[0][i] = cs[i] == 2 || (cs[i] == 1 && l < u);\n        res[1][i] = cs[i] == 2 || (cs[i] == 1 && !res[0][i]);\n    }\n    return u == 0 && l == 0 ? res : vector<vector<int>>();\n}\n```\n**Java**\n```\npublic List<List<Integer>> reconstructMatrix(int u, int l, int[] cs) {\n    boolean[][] res = new boolean[2][cs.length];\n    for (int i = 0; i < cs.length; ++i) {\n        res[0][i] = cs[i] == 2 || (cs[i] == 1 && l < u);\n        res[1][i] = cs[i] == 2 || (cs[i] == 1 && !res[0][i]);\n        u -= res[0][i] ? 1 : 0;\n        l -= res[1][i] ? 1 : 0;\n    }\n    return l == 0 && u == 0 ? new ArrayList(Arrays.asList(res[0], res[1])) : new ArrayList();    \n}\n```
[]