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.❤
@kbcoder37346 сағат бұрын
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.
@shadyboy30104 сағат бұрын
nicely explained, thanks man
@Its_Shubham_Negi11 сағат бұрын
Finally c++❤
@bishwashkumarsah17111 сағат бұрын
11:32 lol i was exactly thinking about this and wanted to take that case as input. haha