Introducing Asymptotic Notations
5:17
How I Got An Internship @ Twitter
6:31
Пікірлер
@joeklinck
@joeklinck 18 сағат бұрын
At 6:40, the nodes are pushed in the order E,D,C,B. This would only happen if the adjacency list was written like this, A:E,D,C,B. While there is nothing technically wrong with that, they would usually be written A:B,C,D,E and thus the stack would look like this (from bottom to top) B,C,D,E and then the first node to get processed and printed after A would be E. The way he did it made the output look nicer because it was all in order, but that is not how it would normally happen, since the conventional way is to write the vertices/nodes in alphabetical order. Although yes, you can write the adjacency vertices/nodes in any order you want.
@sallaklamhayyen9876
@sallaklamhayyen9876 3 күн бұрын
Brilliant as always = thank you so much🥰
@nan066
@nan066 3 күн бұрын
oh my gosh thank you.
@recoverybot777
@recoverybot777 4 күн бұрын
amazingly explained
@heyjoe5920
@heyjoe5920 5 күн бұрын
Man, thank you so much. Great explanation, especially of O(1) space solution.
@mounirzouhari6453
@mounirzouhari6453 5 күн бұрын
wow this is the best explanation
@LizyAd
@LizyAd 6 күн бұрын
Perfect explanation. Thanks
@CometSpy
@CometSpy 6 күн бұрын
Thanks man :)
@ChideraAbaraonye
@ChideraAbaraonye 6 күн бұрын
You're the best teacher ever, and I'm being VERY honest. You have helped me understand concepts I used to struggle with
@ChideraAbaraonye
@ChideraAbaraonye 6 күн бұрын
I love you man
@aadilbutt8809
@aadilbutt8809 6 күн бұрын
WOW BRO EXPLAINED PRETTY WELL AS AN STARTER WHO WANTED VISUALIZATION I UNDERSTOOD PRETTY MUCH BRO DESERVE MORE LIKES
@ChideraAbaraonye
@ChideraAbaraonye 7 күн бұрын
The best explanation i have ever gotten for this problem. I am sure i will never forget how to solve this problem again. thanks man
@kjk2973
@kjk2973 7 күн бұрын
i don't comment often but i have to say nice work, your explanation was very helpful
@IshraqTanvir
@IshraqTanvir 8 күн бұрын
hey I don't know ur name! But u just made a fan from bangladesh...Love u a lot.....ur explanation all over the youtube is just wiinning.....THank u very much..............we wanna see more
@kshitij3394
@kshitij3394 8 күн бұрын
Bro really loved your way of explanation. Kudos 👏
@qinyunli152
@qinyunli152 8 күн бұрын
Java:class Solution { public List<Integer> distanceK(TreeNode root, TreeNode target, int k) { Map<Integer, List<Integer>> graph = new HashMap<>(); dfsBuildGraph(root, null, graph); List<Integer> res = new ArrayList<>(); Set<Integer> visited = new HashSet<>(); Queue<int[]> queue = new LinkedList<>();// int[] node and distance = new int[2]; {node.val,distance of graph from target} queue.add(new int[]{target.val, 0}); // start from target to transverse the graph : level k=0 level k=1 level k=2.... visited.add(target.val); //skip the visited point while(!queue.isEmpty()){ int[] cur = queue.poll(); int node = cur[0]; int distance = cur[1]; if(distance == k){ res.add(node); continue; } //undirected graph: node and its neighbor for(int neighbor: graph.getOrDefault(node, new ArrayList<>())){ if(!visited.contains(neighbor)){ visited.add(neighbor); queue.add(new int[]{neighbor, distance + 1});// [5,0][6,1][2,1][3,1][7,2][4,2].... } } } return res; } // Recursively build the undirected graph from the given binary tree. public void dfsBuildGraph(TreeNode cur, TreeNode parent, Map<Integer, List<Integer>> graph){ if(cur != null && parent != null){ int curVal = cur.val; int parentVal = parent.val; graph.putIfAbsent(cur.val, new ArrayList<>()); graph.putIfAbsent(parent.val, new ArrayList<>()); graph.get(cur.val).add(parent.val); graph.get(parent.val).add(cur.val); } if(cur != null && cur.left != null){ dfsBuildGraph(cur.left, cur, graph);// (5,3,graph)--> map(5,new arraylist{3}) map(3,new arraylist{5}) } // (6,5,graph)--> map(5,new arraylist{3,6}) map(3,new arraylist{5} map(6,new arraylist{5}) if(cur != null && cur.right != null){ dfsBuildGraph(cur.right, cur, graph); } } } // question :root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, k = 2
@teeheeee7807
@teeheeee7807 9 күн бұрын
Thank u so much sir❤keep doing
@kushagrakulshrestha2966
@kushagrakulshrestha2966 9 күн бұрын
CODE ➡➡ : Hello guyz, shoutout to srikant in comments for providing this random code that WORKS , not sure if it's the same as youtubers code or not, KINDLY like my comment so everyone can have code , youtuber is playing pranks with us.... enjoy and GL public Node cloneGraph(Node node) { return cloneGraphWithVisited(node, new HashMap<Integer, Node>()); } public Node cloneGraphWithVisited(Node node, Map<Integer, Node> visited) { if (node == null) return null; if (visited.containsKey(node.val)) return visited.get(node.val); Node clone = new Node(node.val, new ArrayList<Node>()); visited.put(node.val, clone); for(Node neighbor: node.neighbors) { clone.neighbors.add(cloneGraphWithVisited(neighbor, visited)); } return clone; } //ez
@darshnadrisha
@darshnadrisha 10 күн бұрын
How did you get an internship offer from JP Morgan?I'm Mtech 1st yr student
@cisemayaz6662
@cisemayaz6662 10 күн бұрын
what the func
@sid-oz8fw
@sid-oz8fw 12 күн бұрын
5 years later this man is still the goat
@jitpatel1105
@jitpatel1105 13 күн бұрын
Thank You for the best Explanation
@JogoShugh
@JogoShugh 15 күн бұрын
This is freaking awesome. Thank you.
@AyazNcfli
@AyazNcfli 17 күн бұрын
Great!!! 👏👏👏👏
@Adam-tz6gk
@Adam-tz6gk 17 күн бұрын
Outstanding explanation thank you so much
@cozzi6995
@cozzi6995 18 күн бұрын
have my kids
@GeeMmm-i9h
@GeeMmm-i9h 18 күн бұрын
The best explanation of this problem I've seen so far. Many other talks surprisingly don't even explain the definition of the cells in the DP table, or what is the logic behind the recursion. I wish all of the teachers and speakers were like this guy. Such a beautiful talk!!!
@junaiid0104
@junaiid0104 18 күн бұрын
legend😭😭😭😭🙌🏻
@junaiid0104
@junaiid0104 19 күн бұрын
thank you sir!
@ShikharKumar-fz6ti
@ShikharKumar-fz6ti 21 күн бұрын
Amazing video, do you have one of these Maze path for BFS, A*, Uniform Cost Search?
@tanziyang2771
@tanziyang2771 22 күн бұрын
Awesome video :D
@tweede5555
@tweede5555 22 күн бұрын
Hey man, long time subscriber here. 3 years ago I watched most videos on your channel and you are by far the greatest teacher I've had. I wish more people in the industry taught like you did - Clear and concise! You helped me crack my FAANG new grad interview, and now I'm back to get some refreshers to crack another FAANG possibly 😂. Just wanted to shout you out before I started my journey. THANK YOU! 🙏🏿
@NiaNewton
@NiaNewton 23 күн бұрын
wow you made this so easy, thank you!
@AkashJha-q3r
@AkashJha-q3r 24 күн бұрын
excellent explanation
@TimonSchneider-e7b
@TimonSchneider-e7b 24 күн бұрын
Good one!
@sher.5027
@sher.5027 25 күн бұрын
Massive respect. 🎉🎉
@21daysfromnow
@21daysfromnow 26 күн бұрын
I never comment but you were really helpful
@tuandino6990
@tuandino6990 27 күн бұрын
Im telling you im scrolling through these knapsack videos on youtube, and yours by far are the easiest to understand. I wont need to scroll anymore
@kwayfo6923
@kwayfo6923 28 күн бұрын
very helpful!
@LizyAd
@LizyAd 29 күн бұрын
Watching from Chicago and love this so much! Thanks for clarifying this algorithm.
@ioeentrancepreparation6178
@ioeentrancepreparation6178 29 күн бұрын
@NalikaRu
@NalikaRu 29 күн бұрын
really helpfull
@brianzhang8189
@brianzhang8189 Ай бұрын
A fun fact about the change-making problem is that we can attempt to solve it using a greedy algorithm, where we always pick the largest available denomination at each step and hope for the best. For example, suppose we have coins of denominations [1, 3, 7, 10] and we want to make 14. Using the greedy algorithm, we would choose 10, then 3, and then 1, resulting in a total of 3 coins. However, this is not optimal, as the optimal solution is to use two 7s, resulting in only 2 coins. However, there is the concept of a canonical currency system where making the greedy choice does in fact always result in an optimal solution. Nearly all modern currencies are designed this way to make it easier for the public to make change without extra mental overhead. Take US coins for example, they come in denominations of 1, 5, 10, and 25 cents. Using the greedy algorithm using this set of coins will always produce an optimal solution to the change making problem
@nuttyspasmaloid4587
@nuttyspasmaloid4587 Ай бұрын
the clearest explanation ive seen, saved me from having to do hours of catchup xd
@All-Inclusive_Corner
@All-Inclusive_Corner Ай бұрын
Best teacher. I highly recommend this video .
@YouthWaster
@YouthWaster Ай бұрын
Why don't we boycott universities and watch videos like this? Thanx man <3
@drikast
@drikast Ай бұрын
Thank you 😎
@emirhandemir3872
@emirhandemir3872 Ай бұрын
Perfect explanation and perfect video. Everything was perfect untill I realized the fact that you didn't do average analysis until the end of the video :>(
@matthewzarate8851
@matthewzarate8851 Ай бұрын
Seemed super long winded that I couldn't see how the smaller subproblems helped us solve future subproblems...:/
@tahakamali6196
@tahakamali6196 Ай бұрын
god bless you