AlgoLib.io - Master 72+ Algorithms with Interactive Visualizations
Free and open-source algorithm library for developers, students, and competitive programmers.
Learn data structures and algorithms with step-by-step visualizations, clean code examples in
Python, Java, C++, and TypeScript, and direct links to LeetCode practice problems.
Why AlgoLib.io?
- 72+ Algorithm Implementations - Comprehensive coverage from basic to advanced
- Interactive Visualizations - See algorithms in action with step-by-step animations
- Multi-Language Code - Examples in Python, Java, C++, and TypeScript
- LeetCode Integration - Direct links to practice problems
- Complexity Analysis - Time and space complexity for every algorithm
- 100% Free & Open Source - No paywalls, no subscriptions, forever free
Algorithm Categories
Arrays & Strings
-
Two Pointers
- Use two pointers to traverse arrays efficiently
(Time: O(n), Space: O(1))
-
Sliding Window
- Maintain a window of elements for efficient computation
(Time: O(n), Space: O(k))
-
Prefix Sum
- Pre-compute cumulative sums for range queries
(Time: O(n), Space: O(n))
-
Binary Search
- Search in sorted arrays in logarithmic time
(Time: O(log n), Space: O(1))
-
Kadane's Algorithm
- Find maximum subarray sum efficiently
(Time: O(n), Space: O(1))
-
Dutch National Flag
- Sort array of three distinct elements
(Time: O(n), Space: O(1))
-
Merge Intervals
- Merge overlapping intervals
(Time: O(n log n), Space: O(n))
-
Monotonic Stack
- Stack with monotonic properties for efficient queries
(Time: O(n), Space: O(n))
-
Rotate Array In-Place
- Rotate array elements without extra space
(Time: O(n), Space: O(1))
-
Cyclic Sort
- Sort by placing elements at their correct index
(Time: O(n), Space: O(1))
Trees & BSTs
-
DFS Preorder
- Visit root, left, then right subtree
(Time: O(n), Space: O(h))
-
DFS Inorder
- Visit left, root, then right subtree
(Time: O(n), Space: O(h))
-
DFS Postorder
- Visit left, right, then root
(Time: O(n), Space: O(h))
-
BFS Level Order
- Traverse tree level by level
(Time: O(n), Space: O(w))
-
BST Insert
- Insert node in binary search tree
(Time: O(log n), Space: O(h))
-
Lowest Common Ancestor
- Find LCA of two nodes in tree
(Time: O(n), Space: O(h))
-
Recover BST
- Fix BST with two swapped nodes
(Time: O(n), Space: O(h))
-
Serialize Tree
- Serialize and deserialize binary tree
(Time: O(n), Space: O(n))
-
Trie (Prefix Tree)
- Efficient string storage and retrieval
(Time: O(m), Space: O(n*m))
Graphs
-
Graph DFS
- Depth-first traversal of graphs
(Time: O(V+E), Space: O(V))
-
Graph BFS
- Breadth-first traversal of graphs
(Time: O(V+E), Space: O(V))
-
Topological Sort
- Kahn's algorithm for DAG ordering
(Time: O(V+E), Space: O(V))
-
Union-Find
- Disjoint set data structure
(Time: O(α(n)), Space: O(n))
-
Kruskal's Algorithm
- Find minimum spanning tree
(Time: O(E log E), Space: O(V))
-
Prim's Algorithm
- Find MST using greedy approach
(Time: O(E log V), Space: O(V))
-
Dijkstra's Algorithm
- Single-source shortest path
(Time: O((V+E) log V), Space: O(V))
-
Bellman-Ford
- Shortest path with negative weights
(Time: O(VE), Space: O(V))
-
Floyd-Warshall
- All-pairs shortest paths
(Time: O(V³), Space: O(V²))
-
A* Search
- Heuristic pathfinding algorithm
(Time: O(b^d), Space: O(b^d))
Dynamic Programming
-
0/1 Knapsack
- Maximize value with weight constraint
(Time: O(nW), Space: O(nW))
-
Coin Change
- Minimum coins for target amount
(Time: O(nW), Space: O(W))
-
Longest Common Subsequence
- Find longest common subsequence
(Time: O(mn), Space: O(mn))
-
Longest Increasing Subsequence
- Find LIS in array
(Time: O(n log n), Space: O(n))
-
Edit Distance
- Minimum edits to transform strings
(Time: O(mn), Space: O(mn))
-
Matrix Path DP
- Find unique or minimum paths in matrix
(Time: O(mn), Space: O(mn))
-
Partition Equal Subset
- Check if array can be partitioned equally
(Time: O(n*sum), Space: O(sum))
-
House Robber
- Maximum sum without adjacent elements
(Time: O(n), Space: O(1))
-
Climbing Stairs
- Count ways to climb n stairs
(Time: O(n), Space: O(1))
-
Word Break
- Segment string into dictionary words
(Time: O(n²), Space: O(n))
Greedy
-
Activity Selection
- Select maximum non-overlapping activities
(Time: O(n log n), Space: O(1))
-
Interval Scheduling
- Schedule intervals optimally
(Time: O(n log n), Space: O(1))
-
Huffman Encoding
- Optimal prefix-free encoding
(Time: O(n log n), Space: O(n))
-
Gas Station
- Find starting station for circular tour
(Time: O(n), Space: O(1))
Backtracking
-
Subsets
- Generate all subsets of a set
(Time: O(2^n), Space: O(n))
-
Permutations
- Generate all permutations
(Time: O(n!), Space: O(n))
-
Combinations
- Generate all k-combinations
(Time: O(C(n,k)), Space: O(k))
-
Combination Sum
- Find combinations summing to target
(Time: O(2^n), Space: O(target))
-
Word Search
- Find word in 2D grid
(Time: O(m*n*4^L), Space: O(L))
-
N-Queens
- Place N queens on N×N board
(Time: O(N!), Space: O(N))
-
Sudoku Solver
- Solve Sudoku puzzle
(Time: O(9^(n*n)), Space: O(n*n))
Bit Manipulation
-
XOR Trick
- Find single number using XOR
(Time: O(n), Space: O(1))
-
Count Bits
- Brian Kernighan's algorithm
(Time: O(log n), Space: O(1))
-
Subset Generation with Bits
- Generate subsets using bitmasks
(Time: O(2^n * n), Space: O(1))
Advanced
-
Segment Tree
- Range query data structure
(Time: O(log n), Space: O(n))
-
Fenwick Tree (BIT)
- Binary indexed tree for prefix sums
(Time: O(log n), Space: O(n))
-
Sparse Table
- Range minimum query in O(1)
(Time: O(1), Space: O(n log n))
-
KMP String Matching
- Linear time pattern matching
(Time: O(n+m), Space: O(m))
-
Rabin-Karp
- Rolling hash pattern matching
(Time: O(n+m), Space: O(1))
-
Manacher's Algorithm
- Longest palindromic substring
(Time: O(n), Space: O(n))
-
Union by Rank + Path Compression
- Optimized union-find
(Time: O(α(n)), Space: O(n))
-
Tarjan's Algorithm
- Find strongly connected components
(Time: O(V+E), Space: O(V))
-
Binary Lifting
- LCA using binary lifting
(Time: O(log n), Space: O(n log n))
-
LRU Cache
- Least Recently Used cache implementation using HashMap and Doubly Linked List
(Time: O(1), Space: O(capacity))
Perfect For
- Coding Interview Preparation - Master algorithms asked in FAANG interviews
- Competitive Programming - Learn techniques for Codeforces, AtCoder, and more
- Computer Science Students - Visual learning aids for DSA courses
- LeetCode Practice - Understand algorithms before solving problems
- Self-Taught Developers - Structured learning path for algorithms
Popular Algorithms
Start Learning Today
Browse our complete collection of 75 algorithms, each with detailed explanations,
complexity analysis, code implementations, and practice problems. All completely free and open source.