Course Schedule (Famous Problem) - ua-cam.com/video/7bo6lklvpQI/v-deo.html But getting this in an Interview, we would be self doubting our most Optimal Solution 🫣
Hi @aryan why cant we solve this by first forming a map of the toposort array (element,level in the toposort) so if for (a,b) if map.get(a) is less this means this comes first in toposort but 1 things is left how will this ensure that a,b are connected or not so can use DSU for that so wont then time complexity by just (n^2) i.e. of toposort and dsu just takes ~ o(1) Please suggest am I correct ?
Course Schedule (Famous Problem) - ua-cam.com/video/7bo6lklvpQI/v-deo.html
But getting this in an Interview, we would be self doubting our most Optimal Solution 🫣
Thank you 😊
Hi @aryan why cant we solve this by first forming a map of the toposort array (element,level in the toposort) so if for (a,b) if map.get(a) is less this means this comes first in toposort
but 1 things is left how will this ensure that a,b are connected or not so can use DSU for that so wont then time complexity by just (n^2) i.e. of toposort and dsu just takes ~ o(1)
Please suggest am I correct ?
Explained well !
code quality
brother where is 3435. Frequencies of Shortest Supersequences
Topo sort is fine but dfs also works right given the bound is only 100 ?
Yes
thanks bhaiya 🙏
Bad explanation 😢