Lesson overview · Free interview practice

Shortest Path Algorithms

Determine the shortest paths between nodes in a graph.

Topics in the full lesson
  • Concept and Use Cases
  • Key Concepts
  • Time and Space Complexity
  • Shortest Path Algorithms and Methods
  • Practical Tips and Tricks
  • Common Gotchas
  • Advanced Topics
  • Interview Tips and Tricks
  • Common Mistakes

Try the free interview questions

Work through a question before revealing its explanation. These questions and answers are free; Premium adds the full lesson walkthrough, examples and implementation detail.

Question

You are given a rows x cols grid heights, where heights[r][c] is the height of cell (r, c). Starting at the top-left cell, you want to reach the bottom-right cell, moving up, down, left, or right. A route's effort is the maximum absolute difference in heights between two consecutive cells along it. Return the minimum effort required to travel from the top-left cell to the bottom-right cell.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

CodingMedium

Network Delay Time

Question

A signal is sent from node K in a directed weighted graph with N nodes, where times[i] = [u, v, w] is an edge from u to v that takes w time. Return the time for all N nodes to receive the signal, or -1 if any node is unreachable.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Explore the full Shortest Path Algorithms material

Premium includes the complete lessons and implementation references. Free practice questions remain available without a subscription.

All course tracks & premium content
From basics to advanced masterclasses
Built for JS/TS developers like you
Real-world tips & common pitfalls
Upgrade to Premium

Continue in this section