class Solution { public: // Function to return the adjacency list for each vertex. vector<vector<int>> printGraph(int V, vector<int> adj[]) { vector<vector<int>> v2; for(int i=0;i<V;i++) { vector<int> v1; v1.push_back(i); for(int j=0;j<adj[i].size();j++) { v1.push_back(adj[i][j]); } v2.push_back(v1); } return v2; } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter