JavaScript Coding Interview: Graphs and Heaps

Bartosz Zaczyński 20 Lessons 3h 57m Updated intermediate career

Graph and heap problems are where coding interviews stop looking like array puzzles. The data is a web of connections, such as packages that depend on packages, tiles on a game map, or services that call other services, or it’s a stream where only the top few items matter. That’s also where AI-written code tends to go quietly wrong.

An assistant can produce a breadth-first search in seconds. Someone still has to notice when it forgets where it’s been, drains its queue with shift() on a graph with fifty thousand nodes, or sorts a million log lines to find the ten slowest. That someone is you.

In this course, you’ll practice two patterns that go together more often than you’d think:

  • Graphs and grids, where you store neighbors in a Map, keep a Set of what you’ve visited, and choose between a depth-first walk and a level-by-level one depending on whether the question is about reaching something or about distance
  • Heaps, which keep the smallest or largest item ready at the top. JavaScript has no built-in heap, so you’ll build a small MinHeap class yourself and then use it to pick the top k items and merge sorted streams

Every problem is set in a realistic web-app scenario, from npm dependency graphs and circular imports to a paint-bucket tool, trending hashtags, and merged server logs, and it runs in your browser on Node 26.

Your first goal is a working solution. Then a bonus test plays the interviewer’s follow-up and checks whether your solution still holds up at scale.

Along the way, you’ll review an AI-written function that finds the shortest chain between two people, test your pattern spotting in a quiz, and finish with a mock interview scored on communication, problem solving, code quality, and testing.

What’s Included:

  • 20 Lessons
  • Video Subtitles and Full Transcripts
  • Translated Subtitles in 8 Languages
  • 2 Downloadable Resources
  • Interactive Quiz to Check Your Progress
  • 11 Hands-On Coding Exercises
  • Q&A With JavaScript Experts: Ask a Question
  • Certificate of Completion

Downloadable Resources:

Related Learning Paths:

Getting Started

1 Lesson 1m

  1. 1. Welcome to Graphs and Heaps01:40

About Bartosz Zaczyński

Bartosz is an experienced software engineer and programming educator with an M.Sc. in Applied Computer Science.

» More about Bartosz

Each tutorial at RealJS is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

← Browse All Courses