Understandable and concise code in C++
Probably, you have already checked other solutions from the discussions and got the idea that this problem can be solved using a greedy approach.\nHere is one o
Probably, you have already checked other solutions from the discussions and got the idea that this problem can be solved using a greedy approach.\nHere is one of the variations of implementing it. \n```c++\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        if (accumulate(begin(colsum), end(colsum), 0) != upper + lower) return vector<vector<int>>{};\n        vector<vector<int>> res(2, vector<int>(colsum.size(), 0));\n        fillRow(0, upper, colsum, res);\n        fillRow(1, lower, colsum, res);\n        return res;\n    }\nprivate:\n    void fillRow(int index, int values, vector<int>& colsum, vector<vector<int>>& res) {\n        for (int i = 0; i < colsum.size(); i++) {\n            int temp = min(colsum[i], values);\n            res[index][i] = temp;\n            colsum[i] -= temp;\n            values -= temp;\n        }\n    }\n};\n```
['Greedy']