||  Easy solution in C++||
Intuition\n Describe your first thoughts on how to solve this problem. \nSince we have given the RowCon and ColCon like nodess and we have to sort them. Therefo
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSince we have given the RowCon and ColCon like nodess and we have to sort them. Therefore the first thing came to mind is Topological Sort.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIt follows a simple Approach.\nFind the Toposort of rowCondition and colCondition.\nIt will give u the order of the arrangement in rows and cols.\nNow for each node check the cell which is common for both row and col.\nPlace the node in that cell.\nIf rowCondition and colCondition doesn\'t take care of all the nodes then we can randomly arrange them at last.\nMake all the remaining cells as 0\n# Complexity\n- Time complexity:\nThe time complexity of this solution is O(n + m + k),\n- Space complexity:\nThe space complexity is O(k), \n\n# Code\n```\nclass Solution {\nprivate:\n    vector<int> TopoSort(int k, vector<vector<int>>& adj)\n    {\n        vector<int> indegree(k+1, 0);\n        for(int node=1; node<=k; node++)\n            for(auto it : adj[node])\n                indegree[it]++;\n\n        queue<int> q;\n        vector<int> vis(k+1, 0);\n        for(int node=1; node<=k; node++)\n            if(indegree[node]==0)\n                q.push(node);\n\n        vector<int> ans;\n        while(!q.empty())\n        {\n            int n = q.size();\n            while(n--)\n            {\n                int node = q.front();\n                q.pop();\n\n                vis[node] = true;\n                ans.push_back(node);\n\n                for(auto it : adj[node])\n                {\n                    if(!vis[it])\n                    {\n                        indegree[it]--;\n                        if(indegree[it]==0) \n                            q.push(it);\n                    }\n                }\n            }\n        }\n\n        vector<int> notTopo;\n        for(int node=1; node<=k; node++) \n            if(indegree[node] != 0) \n                return notTopo;\n        return ans;\n    }\n\n    void fillTopoArray(int k, vector<int>& arr)\n    {\n        unordered_map<int, bool> mp;\n        for(auto it : arr) \n            mp[it] = true;\n\n        for(int i=1; i<=k; i++)\n            if(!mp[i]) \n                arr.push_back(i);\n    }\npublic:\n    vector<vector<int>> buildMatrix(int k, vector<vector<int>>& rowConditions, vector<vector<int>>& colConditions) \n    {\n        int n=rowConditions.size(),m=colConditions.size();\n\n        vector<vector<int>> adjRow(k+1);\n        vector<vector<int>> adjCol(k+1);\n\n        for(auto it: rowConditions)\n            adjRow[it[0]].push_back(it[1]);\n        \n        for(auto it: colConditions)\n            adjCol[it[0]].push_back(it[1]);\n\n        //Apply Toposort\n\n        vector<int> rowTopo=TopoSort(k,adjRow);\n        vector<int> colTopo=TopoSort(k,adjCol);\n        vector<vector<int>> ans;\n\n        //Base case\n        if(rowTopo.size()==0 || colTopo.size()==0)\n            return ans;\n        \n\n        fillTopoArray(k, rowTopo);\n        fillTopoArray(k, colTopo);\n\n        unordered_map<int, int> mp;\n        for(int j=0; j<k; j++)\n            mp[colTopo[j]] = j;\n\n        ans = vector<vector<int>>(k, vector<int>(k, 0));\n        for(int i=0; i<k; i++)\n            ans[i][mp[rowTopo[i]]] = rowTopo[i];\n        \n        return ans;        \n    }\n};\n```
['Array', 'Graph', 'Topological Sort', 'Matrix', 'C++']