Good to see simple dfs intuition in this video which i were looking, but i have one doubt doubt:- at 23:04 in video how simple dfs will get (2, 1) pair along with (1, 2) as he got in first. we mark 1 as visited in simple dfs and then move it's nbr( which is 2) then now we will do dfs from 2 and move to it's nbr(which is 1 and visited) then we will not be getting.
@rajrajesh16692 күн бұрын
This problem literally questioned my skills 😢. Usually, I'll try to avoid incorrect approaches by validating my thoughts but however for this problem I thought it's actually an easy-hard one, by assuming that each node will only have one edge, so I directly jumped to write an O(n) hash solution without DFS but after submission I realised the mistake. Then even though I know just a blind DFS from every starting point will not solve the problem due to the constraints, I wanted to just code it then if I get a TLE then I thought I'll read leetcode editorials for efficient solution if it's not enough then watch your video editorial. But there was yet another problem, I misjudged it again because I missed the backtracking part. After covering that part I again failed not by TLE but with my DFS itself, I spent about 2hrs just to debug and figure out what went wrong. After going through all these, I finally decided to give up and here I am. Basically, I went through every single wrong direction you explained, lol. No one can explain a solution with this level of care and effort, that's why you are the best. Thanks again for the wonderful editorial, Aryan bro. Finally, inner peace.❤
@nikhilprakash729Күн бұрын
Awesome Explanation Bhaiya
@kbcoder37342 күн бұрын
Really Nice Solution, one improvement could be using the vector ans to store the answer in the dfs, So that at the end we don't need to convert the result to the required format again.
@shadyboy30102 күн бұрын
nicely explained, thanks man
@Its_Shubham_Negi2 күн бұрын
Finally c++❤
@priyanshupriyam174Күн бұрын
I am only believe on Aryan bhai because game changer person there is only one that is the Aryan Mittal!
@bishwashkumarsah1712 күн бұрын
11:32 lol i was exactly thinking about this and wanted to take that case as input. haha
@josephsamuelm4608Күн бұрын
One doubt : At 28:02 how are we making sure that 1,3 is at the end, just by post order traversal? What if the adjacency list is 1->2,3,4 and 2->1 and 4->1 then 1,3 won't be coming first in the post order traversal right. It will be 1,4 that comes first, right?