LeetCode 207 & 210: Course Schedule I & II | Topological Sort | Kahn's algorithm - Interview Ep 78.2

  Рет қаралды 4,074

Fisher Coder

Fisher Coder

Күн бұрын

⭐ Shop on Amazon to support me: www.amazon.com...
⭐ NordVPN to protect your online privacy: go.nordvpn.net...
⭐ NordPass to help manage all of your passwords: go.nordpass.io...
This is the 2nd part of topological sort talking about applying Kahn's algorithm to solve LeetCode problems.
Link to the full video: • Video
Problem link on LeetCode:
Course Schedule: leetcode.com/p...
Course Schedule II: leetcode.com/p...
⭐ Support my channel and connect with me:
/ @fishercoder
Algorithm explained:
we first find a set of vertices that don't have any incoming edges;
then we loop through these vertices to remove any edges using them as incoming vertices;
along the way, if we find other vertices don't have any incoming edges any more, we'll add them into this set as well;
until this set becomes empty, we break out of this loop;
then we check if there are still any edges there, if so, this is a DAG (Directed Acyclic Graph), it's impossible to find such a topological ordering.
Otherwise, return the order.
Time complexity: O(V+E) (V is the number of vertices and E is the number of edges in the given graph)
// TOOLS THAT I USE:
○ Memory Foam Set Keyboard Wrist Rest Pad - amzn.to/3cOGOAj
○ Electric Height Adjustable Standing Desk - amzn.to/2S9YexJ
○ Apple Magic Keyboard (Wireless, Rechargable) - amzn.to/36gy5FJ
○ Apple Magic Trackpad 2 (Wireless, Rechargable) - amzn.to/36ltimu
○ Apple MacBook Pro - amzn.to/30iSvKE
○ All-In One Printer - amzn.to/34etmSi
○ Apple AirPods Pro - amzn.to/2GpVYQf
○ My new favorite Apple Watch - amzn.to/2EIIUFd
// MY FAVORITE BOOKS:
○ Introduction to Algorithms - amzn.to/36hxHXD
○ Designing Data-Intensive Applications - amzn.to/2S7snOg
○ Head First Java - amzn.to/2ScLDKa
○ Design Patterns - amzn.to/2SaGeU2
Follow me on Github for complete LeetCode solutions: github.com/fis...
Support me on Patreon: / fishercoder
My ENTIRE Programming Equipment and Computer Science Bookshelf:
www.amazon.com...
And make sure you subscribe to my channel!
Your comments/thoughts/questions/advice will be greatly appreciated!
#Kahnsalgorithm #graphsearch #topologicalsorting #softwareengineering #leetcode #algorithms #coding #interview #SDE #SWE #SiliconValley #programming #datastructures

Пікірлер: 5
@joellew8655
@joellew8655 2 жыл бұрын
Thank you for making this video! This is probably the best video to understand topological sort! I am just curious how do you have dark mode on LeetCode?
@FisherCoder
@FisherCoder 2 жыл бұрын
Glad it was helpful!
@karankanojiya7672
@karankanojiya7672 2 жыл бұрын
Excellent Sir ! But one query is, why we used HashSet here we can also Queue here normal BFS approach ? 📌 Code Using Queue class Solution { public boolean canFinish(int n, int[][] p) { if(p.length==0) return true; //initialize indegree int inDegree[]=new int[n]; //indegree calculation for(int[] c:p) inDegree[c[0]]++; Queue queue=new LinkedList(); for(int i=0;i
@ramko685
@ramko685 4 жыл бұрын
Hey! I saw on your LC that you go or went to the University of Minnesota? I am going to be an incoming freshman there
@FisherCoder
@FisherCoder 4 жыл бұрын
Yes! I did! I graduated from UMN in 2014, it's a great university! Your time there will be unforgettable and fruitful!
Course Schedule II - Topological Sort - Leetcode 210
17:09
NeetCode
Рет қаралды 154 М.
My Daughter's Dumplings Are Filled With Coins #funny #cute #comedy
00:18
Funny daughter's daily life
Рет қаралды 29 МЛН
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 77 МЛН
Un coup venu de l’espace 😂😂😂
00:19
Nicocapone
Рет қаралды 10 МЛН
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 7 МЛН
G-24. Course Schedule I and II | Pre-requisite Tasks | Topological Sort
11:32
Leetcode - Course Schedule (Python)
9:47
Timothy H Chang
Рет қаралды 10 М.
Viral Video of a Man's Crazy Job Interview
16:02
Darryl Vega TV
Рет қаралды 1,3 МЛН
Medium Google Coding Interview With Ben Awad
51:27
Clément Mihailescu
Рет қаралды 1,3 МЛН
Course Schedule - Graph Adjacency List - Leetcode 207
15:47
NeetCode
Рет қаралды 358 М.
Best Books for Learning Data Structures and Algorithms
14:01
Engineering with Utsav
Рет қаралды 368 М.
Topological sort | Course schedule 2 | Leetcode #210
12:51
Techdose
Рет қаралды 92 М.
How to stand out of 99% of Software Engineers
8:45
Ashhad Ahmad
Рет қаралды 75 М.
My Daughter's Dumplings Are Filled With Coins #funny #cute #comedy
00:18
Funny daughter's daily life
Рет қаралды 29 МЛН