lol I did solve it myself and ended up creating an adj list again sad...made up three states... Your videos are always the most efficient solutions to exist!
there is no need for hashmap. A simple array of length n is enough. graph contains arrays of children of each node and the children array contains the index.
Solved it on my own, but now it’s become a habit to watch your videos daily (after solving/trying problems on leetcode).
same
same
Code solutions in other languages: neetcode.io/solutions/find-eventual-safe-states
1:26. Node 4 is not a terminal node as mentioned in the video
Solved it on my own for the first time
1:28 I think 4 has an outgoing edge therefore is not a terminal node. great solution anyway
lol I did solve it myself and ended up creating an adj list again sad...made up three states... Your videos are always the most efficient solutions to exist!
Thank you for the daily. If I'm not wrong I think you've done this problem already once
yeah. this is old video of his. likes are 1.5k on the problem. now its 6k.
by the way are you from US ?
I thought DFS is too long but forgot about cache
I thought the exact solution but I am unable to put in code
there is no need for hashmap. A simple array of length n is enough. graph contains arrays of children of each node and the children array contains the index.
Do you want to use boolean array?
God I love the feeling of thinking you can solve it in 15 minutes only to get TLE:d at the 2 hour mark...
this way, the cycle detection is not that clear.
I was able to do this on my own, but it wasn't the most efficient solution.
I got TLE for this solution in c++
First comment! 🤗