Graph Algorithms for Technical Interviews – Full Course

Ecommerce Empire Academy

Learn how to implement graph algorithms and how to use them to solve coding challenges.

✏️ This course was developed by Alvin Zablan from Structy. Check out Alvin's channel:

🔗 Learn data structures and algorithms:

⭐️ Course Contents ⭐️
⌨️ (0:00:00) course introduction
⌨️ (0:02:23) graph basics
⌨️ (0:07:10) depth first and breadth first traversal
⌨️ (0:29:13) has path –
⌨️ (0:42:11) undirected path –
⌨️ (1:00:44) connected components count –
⌨️ (1:13:29) largest component –
⌨️ (1:24:03) shortest path –
⌨️ (1:39:36) island count –
⌨️ (1:58:52) minimum island –
⌨️ (2:12:05) outro

🎉 Thanks to our Champion and Sponsor supporters:
👾 Wong Voon jinq
👾 hexploitation
👾 Katia Moran
👾 BlckPhantom
👾 Nick Raker
👾 Otis Morgan
👾 DeezMaster
👾 Treehouse
👾 AppWrite

Learn to code for free and get a developer job:

Read hundreds of articles on programming:

And subscribe for new videos on technology every day:

32 thoughts on “Graph Algorithms for Technical Interviews – Full Course”

  1. Alvin the Programmer

    Hey Programmers! Thanks for checking out the course and I hope you find it useful as you prepare for those tech interviews. If you enjoyed this content, be sure to check out Structy for more data structure and algorithm tutorials from me. Links in the description!

    There I cover all of the common interview topics and you can code along and run test cases directly on the platform. You’ll also be able to find video walkthroughs for every problem in JavaScript and Python, (more language support coming soon!).


    1. Zhoufeng Zheng

      Hi, Alvin, your videos are great! I have learn a lot, thank you so much.
      one more thing is that,
      Is there a reason you are using object (‘{}’), instead of using hashMap?

    2. osagie osemwota

      hello please i need help…on the Largest Component question, i decided to not use the recursive method in my DFS function but i am stuck in a bug… Every single one of the test cases on structy works except the first…here is my code :

      // Write a function, largestComponent, that takes in the adjacency list of an undirected graph. The function should return the size of the largest connected component in the graph.

      const largestComponent = (graph) => {
      let largest=0;
      //keep a track of visited nodes
      let visited = new Set();

      // loop through the graph object
      for (node in graph) {
      if(visited.has(String(node))) continue;
      let currentCount = DFS(graph, node, visited);
      largest = Math.max(largest, currentCount);

      return largest;


      const DFS = (graph, node, visited) => {

      let currentCount = 1;
      let stack = [node];


      let current = stack.pop();
      for( neighbor of graph[current]){

      if(visited.has(String(neighbor))) continue;



      return currentCount;

      0: [‘8’, ‘1’, ‘5’],
      1: [‘0’],
      5: [‘0’, ‘8’],
      8: [‘0’, ‘5’],
      2: [‘3’, ‘4’],
      3: [‘2’, ‘4’],
      4: [‘3’, ‘2’]

  2. The course on DP was a winner. Course on Graph algo is another winner. Hope to learn a lot more from you.

    1. @LDAR let’s assume we’re on an alternate universe where leetcode doesn’t have a time limit

  3. This guy is phenomenal. His course on dynamic programming was exceptionally well done as well.

  4. I’d always been scared of learning graphs, even though I wanted to… but this course took my fear away 😎👍🏻 excelente course, as always!

  5. Thanks for the video. To be honest, this is one of the best graph tutorials I have ever witnessed. My core concepts and understanding towards this Data Structure has improved and I really appreciate the efforts you have put in to make this video.🙏

  6. This course is hands-down, unequivocally fantastic!!! Best useful course I’ve seen about graphs. It ties together the algorithms with concrete use cases which just clicked. Thank you for the fantastic job!!!!

  7. Man! you have my respect. This was the best course for getting started with graph problems I have ever seen. Thank You so much.

  8. This course is exceptionally well done. Completely understood the theory and implementation behind them damned graphs.

  9. watched your lecture on Dynamic Programming and now I am here. You are such a phenomenal teacher, thanks a ton for making these tutorials!

  10. Harry Zachariou

    Great video! At 1:00:00 isn’t there a slight optimisation where you add the src to visited, as it will add it twice as it goes back up the stack so could wrap in a conditional to only add to visited if it doesn’t already exist in visited?

  11. This was amazing. I’ve watched a bunch of these types of videos over the years and this is the only one that actually made it look easy. I can actually say I understand this now. Thank you.

  12. This is phenomenal! I was finding Graph problems so difficult before watching this video, and now they seem fairly easy after watching the entire video! Thanks a ton!

  13. TheBarthinator

    Wow amazing how you made me understand graphs and I have extreme comfortability with the recursive approach and queue method. Always struggled understanding these implementations in python but as a web dev it made a lot more sense in JS. Thank you for taking the time to make this video!

  14. This is the only course I’ve found that has successfully got the concept of graphs through my thick skull, it’s been a subject that’s been so hard for me to learn. Thank you for making this!!

  15. Jerald Macachor

    Leetcode – O(n^2) brute force.
    Algoexpert – O(n) linear
    Alvin / Structy – log(n)

  16. I am actually studying C but I have found this video tremendeously helpfull in explaining how graphs are traversed and how not to use return in a bad way when you want to actually make use of recursion to backpedal from dead ends in situations where you don’t find your base case.

    thank you again. subscribed!

  17. Agustin Vargas

    This is fantastic. Makes graphs easy to digest. Thanks for that.

    I did find a minor issue in the island count problem solution.

    It assumes that each row will have the same number of columns. That assumption isn’t described in the problem. So a quick fix would be to run the nested loop to the length of the row instead of fixing it to zero. And doing the same for the inbounds check. That would present an issue in the exploration in that there might not be any map in either direction, so you’ll have to add an existence check in the explore to account for that.

    This way if a row has less coordinates, or more, it would still work properly.

  18. please do a similar video for weighted graphs. alvin has the best teaching style. clear concise with helpful drawings!!!

  19. Aditya Byreddy

    This is amazing. I found it really easy to understand the graph algorithms after referring to this video. Great job, Alvin 🙂

    Small correction in the solution described for checking if a source and destination have a path in an undirected graph. (line no. 8)

    The logic of traversing the neighbors and adding the source node to the visited list has to be part of the condition that validates whether ta node is visited or not.

    if !(visited.has(src)) {
    // add the src to the visitors list
    // recursively traverse through the src neighbors

Comments are closed.