Very easy and commented solution in c++(no complex code)
\tclass Solution {\n\tpublic:\n\t\tvector> reconstructMatrix(int upper, int lower, vector& colsum) {\n\t\t\tint n=colsum.size();\n\t\t\tint i=0;\n\t\t\tvector>r
\tclass Solution {\n\tpublic:\n\t\tvector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n\t\t\tint n=colsum.size();\n\t\t\tint i=0;\n\t\t\tvector<vector<int>>res(2,vector<int>(n,0));\n\t\t\tvector<vector<int>>res1;\n\t\t\twhile(i<n)\n\t\t\t{\n\t\t\t\tif(colsum[i]==2&&upper>0&&lower>0)// if both lower and upper are above 0 then we can only have 2 as column sum\n\t\t\t\t{\n\t\t\t\t\tres[0][i]=1;\n\t\t\t\t\tres[1][i]=1;\n\t\t\t\t\tupper--;\n\t\t\t\t\tlower--;\n\t\t\t\t}\n\t\t\t\telse if(colsum[i]==2)// else return empty vector\n\t\t\t\t{\n\t\t\t\t\treturn res1;\n\t\t\t\t}\n\t\t\t\telse if(colsum[i]==1)\n\t\t\t\t{\n\t\t\t\t\tif(upper>lower&&upper>0)// check if upper > lower and also upper should be greater than 0\n\t\t\t\t\t{\n\t\t\t\t\t\tres[0][i]=1;\n\t\t\t\t\t\tupper--;\n\t\t\t\t\t}\n\t\t\t\t\telse if(lower>=upper&&lower>0)// check if lower>upper and also lower is greater than 0\n\t\t\t\t\t{\n\t\t\t\t\t\tres[1][i]=1;\n\t\t\t\t\t\tlower--;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\treturn res1;// return empty vector\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\tif(upper==0&&lower==0)// at last if we have assigned number of 1 in both rows equals to upper and lower so we are checking if both of them are 0\n\t\t\t{\n\t\t\t\treturn res;\n\t\t\t}\n\t\t\treturn res1; // else return empty vector\n\n\n\n\t\t}\n\t};
[]