Interactive visualizations for data structures and algorithms
Sort an array using the bubble sort algorithm
Sort an array using the selection sort algorithm
Sort an array using the insertion sort algorithm
Move all zeroes to end while maintaining relative order
Find the majority element in an array
Remove duplicates from a sorted array
Find maximum profit from single buy and sell transaction
Rotate an array by k steps
Calculate product of array except self
Find maximum profit from multiple buy and sell transactions
Find number of zero-filled subarrays
Find increasing triplet subsequence
Find the first missing positive integer in an array
Check if s is a subsequence of t
Check if a string is a valid palindrome
Find the longest common prefix in an array of strings
Reverse the words in a string
Find the single number in an array where every other number appears twice
Count the number of 1 bits in the binary representation of a number
Find the two numbers in an array where every other number appears twice
Check if a ransom note can be constructed from a magazine
Find the number of good pairs in an array
Find the maximum number of balloons in a string
Check if an array contains duplicate elements within k distance
Check if two strings are isomorphic
Group anagrams together
Reorganize a string so that no two adjacent characters are the same
Find the longest consecutive sequence in an array
Find the number of good ways to split a string
Merge two sorted arrays into a single sorted array
Find two numbers that add up to target using two pointers on sorted array
Find two lines that form a container with maximum water capacity
Find all unique triplets that sum to zero
Calculate total water trapped between elevation bars after raining
Find longest subarray with equal number of 0s and 1s using hash map
Check if array has subarray (size ≥ 2) with sum that is multiple of k
Find subarrays with sum equal to target using prefix sums
Find subarrays with sum divisible by k using prefix sums
Find maximum average of contiguous subarray of length k using sliding window
Check if s1 is a permutation of s2 using sliding window
Find all anagrams of s1 in s2 using sliding window
Find minimal length subarray with sum ≥ target using variable-size sliding window
Find max consecutive 1s after flipping at most k zeros using sliding window
Find the length of the longest substring without repeating characters
Find the minimum window in string that contains all characters of target
Find the contiguous subarray with the largest sum (Kadane's Algorithm)
Find the contiguous subarray with the largest product (Kadane's Algorithm)
Find the best sightseeing pair in an array
Traverse matrix in spiral order from outer to inner layers
Rotate n×n matrix 90 degrees clockwise using transpose then reverse
Set entire row and column to zero if element is zero using O(1) space
Find the middle node of a linked list
Remove the nth node from the end of a linked list
Reverse a singly linked list using three pointers
Reverse a sublist from position left to right in one pass
Reverse nodes in k-sized groups using iterative in-place reversal
Remove all nodes with duplicate values from a sorted linked list
Merge two sorted linked lists into a single sorted linked list
Detect cycle and find entry point using Floyd's algorithm
Swap every two adjacent nodes in a linked list
Partition a linked list around a value x
Rotate a linked list to the right by k places
Add two numbers represented by linked lists
Deep copy a linked list with random pointers using three-pass interleaving
Flatten a multilevel doubly linked list by inserting child lists inline
Find the node where two linked lists intersect using two pointers
Determine if a string of brackets is properly balanced using a stack
Remove all adjacent duplicates in a string using a stack
Remove duplicate letters from a string to form the lexicographically smallest string
Remove stars from a string
Evaluate a reverse polish notation expression using a stack
Evaluate a basic calculator expression using a stack
Find the longest valid parentheses substring using a stack
Find the next greater element for each element in nums1 using a stack
Find how many days until a warmer temperature using monotonic stack
Find the 132 pattern in an array using a stack
Find the number of visible people in a queue using a stack
Find the largest rectangle area in a histogram using a monotonic stack
Arrange deck so cards are revealed in increasing order using queue simulation
Find the maximum score of a jump game using a queue
Find maximum in each sliding window using monotonic deque
Find the maximum value of equation using a queue
Sort an array of 0s, 1s, and 2s using the quickselect algorithm
Find the kth largest element in an array using a min-heap
Find the insertion position of a target in a sorted array using binary search
Find target in rotated sorted array using modified binary search
Find the peak element in a sorted array using binary search
Find the minimum element in a rotated sorted array using binary search
Find target in sorted 2D matrix using binary search
Generate all subsets using recursive backtracking with decision tree
Generate all permutations by choosing unused elements recursively
Traverse tree level by level using BFS and queue
Traverse tree right side view using BFS and queue
Traverse tree level by level in zigzag pattern using BFS and queue
Connect nodes at same level using BFS with queue
Traverse tree preorder using DFS and stack
Check if two binary trees are identical
Check if a binary tree is symmetric
Find all root-to-leaf paths in a binary tree
Convert a sorted array to a binary search tree
Find the maximum difference between a node and its ancestor in a binary tree
Count downward paths that sum to target using prefix sums and DFS
Traverse tree inorder using DFS and stack
Find the minimum distance between any two nodes in a BST
Check if a binary tree satisfies BST properties using recursive DFS
Find the kth smallest element in a BST using iterative inorder traversal
Traverse tree postorder using DFS and stack
Invert a binary tree using DFS and stack
Find the diameter of a binary tree using recursion
Find the lowest common ancestor of two nodes in a binary tree using recursion
Find duplicate subtrees in a binary tree using serialization
Flatten tree to right-skewed linked list in-place using Morris Traversal
Distribute coins to each node in a binary tree so that every node has exactly one coin
Find maximum amount of money the thief can rob from a binary tree
Find maximum path sum in tree where path can start and end at any node
Find minimum number of cameras to cover all nodes in a binary tree
Trim BST to range [low, high] using recursive pruning and restructuring
Generate product suggestions for each prefix using binary search
Find all words from dictionary in board using Trie and DFS backtracking
Sort characters by frequency using min-heap
Find furthest building reachable with bricks and ladders using min-heap
Find top k frequent elements using min-heap
Find median from data stream using two heaps
Maximize capital by selecting k most profitable projects using max-heap
Find k closest points to origin using max-heap to track distances
Find k pairs with smallest sums using min-heap
Merge k sorted lists using min-heap
Merge all overlapping intervals on a timeline
Insert a new interval into a list of intervals
Find minimum arrows needed to burst all balloons using greedy algorithm
Find maximum number of non-overlapping intervals using greedy algorithm
Find kth smallest element using binary search on value range
Find minimum jumps to reach the end using greedy BFS approach
Find starting gas station to complete circular route using greedy algorithm
Traverse a graph using Depth First Search
Count separate islands in a 2D grid using BFS flood-fill
Find the time needed to inform all employees using DFS with memoization
Find the importance of an employee using DFS with memoization
Clone a graph using DFS
Check if a graph is bipartite using DFS with coloring
Find all nodes exactly K edges away from target using BFS with parent links
Find minimum time for all oranges to rot using multi-source BFS
Find shortest word transformation sequence using BFS
Find valid course order using DFS topological sort on prerequisite graph
Find eventual safe states in a graph using DFS
Find minimum height trees in a graph using BFS
Count connected components in adjacency matrix using DFS
Find redundant connection in a graph using Union-Find
Find minimum cost to connect all points using Kruskal's algorithm
Find the length of the longest increasing subsequence
Find the minimum path sum from top-left to bottom-right in a grid
Find max envelopes that can be Russian dolled using Sort + LIS
Find the number of ways to climb to the top of the stairs
Find the minimum cost to climb to the top of the stairs
Find maximum money to rob from houses using dynamic programming
Find maximum money to rob from houses in a circle using dynamic programming
Find number of unique paths to reach the bottom-right corner of a grid with obstacles using dynamic programming
Find number of square submatrices with all ones using dynamic programming
Find maximum number of points with cost using dynamic programming
Find maximum profit in job scheduling using dynamic programming
Find length of longest subsequence common to both strings using dynamic programming
Find minimum number of operations to convert one string to another using dynamic programming
Find length of longest palindromic subsequence using dynamic programming
Find number of ways to decode a string using dynamic programming
Check if one string matches the pattern using dynamic programming
Count number of ways to get t from s using dynamic programming
Find minimum number of coins to make amount using dynamic programming
Count number of ways to make amount using coins with dynamic programming
Find minimum number of perfect squares that sum to n using dynamic programming
Check if the array can be partitioned into two subsets with equal sum using dynamic programming
Find number of ways to target sum using dynamic programming
Find the minimum weight of the last stone using dynamic programming
Find minimum path sum in a triangle using dynamic programming
175 of 175 algorithms shown