git404hub

trekhleb/javascript-algorithms

195,932JavaScriptAudience · developerComplexity · 1/5LicenseSetup · easy

tl;dr

A JavaScript learning resource with clean implementations of classic algorithms and data structures, each with explanations and links to further reading.

vibe map

mindmap
  root((repo))
    Data Structures
      Linked Lists
      Trees and Graphs
      Hash Tables
      Advanced Structures
    Algorithms
      Searching
      Sorting
      String Matching
      Math Problems
    Learning Features
      Explanations
      YouTube Links
      Beginner to Advanced
    Use Cases
      Interview Prep
      CS Fundamentals
      Algorithm Study

what people make with this

VIBE 1

Prepare for technical interviews by studying implementations of classic algorithms with explanations.

VIBE 2

Learn computer science fundamentals by reading clean, commented JavaScript code instead of pseudocode.

VIBE 3

Study specific data structures or algorithms by browsing individual topic folders with linked resources.

stack

JavaScriptNode.js

setup vibes

Difficulty · easy time til it works · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice and license text.

in plain english

This repository is a learning resource that contains JavaScript-based examples of many popular algorithms and data structures, each accompanied by its own explanations and links to further reading, including YouTube videos. It's aimed at people preparing for technical interviews or studying computer science fundamentals through code they can actually read and run.

The content is organized into two main sections. Data structures cover ways of organizing and storing data efficiently — from beginner-level items like linked lists, queues, stacks, hash tables, and heaps, up to more advanced ones like tries, various tree types, graphs, disjoint sets, bloom filters, and an LRU cache. Algorithms are grouped by topic (Math, Sets, Strings, Searches, and more), spanning factorials and prime factor finding, classic searches and string matching like Knuth-Morris-Pratt and Rabin-Karp, set operations like power sets and the knapsack problem, and mathematical work like discrete Fourier transforms. Each entry is tagged Beginner or Advanced.

Someone would use this when preparing for coding interviews, studying for a computer science course, or wanting to understand classic algorithms by reading clean, commented JavaScript implementations rather than abstract pseudocode. Because each algorithm lives in its own folder with explanations, you can dip in to one topic without going through the whole repository. The codebase is JavaScript with continuous integration tooling set up. The README is also translated into many languages. The full README is longer than what was provided.

prompts (copy fr)

prompt 1
Show me how to implement a binary search tree in JavaScript using the code from this repo as a reference.
prompt 2
Explain the Knuth-Morris-Pratt string matching algorithm using the JavaScript implementation from this repository.
prompt 3
Walk me through the quicksort algorithm step-by-step using the code example from this repo.
prompt 4
How would I use the LRU cache implementation from this repo in a real application?
prompt 5
Help me understand the difference between depth-first and breadth-first search using the graph algorithms in this repo.
peek the repo → explain another one

Generated 2026-05-18 · Model: sonnet-4-6 · double-check against the repo, no cap.