Help needed , CSES Longest Flight Route , [Graph Problem 11]

Ok here is the code that you need to do after topsort

for(auto x:topsort){
	for(auto y:graph[x]){
		if(lvl[x] + 1 > lvl[y]){
			lvl[y] = lvl[x] + 1;
			last[y] = x;
		}
	}
}

here lvl keeps track of the distance from root the particular node and last keeps track of previous number of array