Algorithms Cheatsheet

A collection of common algorithms and data structures implemented in TypeScript with examples from LeetCode problems.

Fixed Sliding Window Algorithm

A technique to process arrays or strings by maintaining a fixed-size window that slides through the data

Dynamic Sliding Window Algorithm

A technique to process arrays or strings by maintaining a variable-size window that adjusts based on specific conditions

Linked List Reverse

A technique to reverse a linked list by changing the direction of pointers

Fast and Slow Pointer

A technique using two pointers moving at different speeds to solve linked list problems

Binary Tree DFS (Depth-First Search)

A technique to traverse or search a binary tree by exploring as far as possible along each branch before backtracking

Binary Tree BFS (Breadth-First Search)

A technique to traverse or search a binary tree by exploring all nodes at the present depth before moving to nodes at the next depth level

Heap Data Structure

A specialized tree-based data structure that satisfies the heap property

Priority Queue

A data structure that serves elements based on their priority rather than their insertion order

Graph DFS (Depth-First Search)

A technique to traverse or search a graph by exploring as far as possible along each branch before backtracking

Graph BFS (Breadth-First Search)

A technique to traverse or search a graph by exploring all neighbors at the present depth before moving to nodes at the next depth level

Trie (Prefix Tree)

A specialized tree-based data structure used for efficient retrieval of keys in a dataset of strings

Backtracking

A general algorithmic technique that considers searching every possible combination to solve a computational problem

Dynamic Programming

A method for solving complex problems by breaking them down into simpler subproblems and storing their solutions to avoid redundant computations