Rulcode.com is an open-source platform to learn, visualize, and master algorithms with interactive explanations and multi-language code snippets (Python, Java, C++, and TypeScript).
🌐 Visit Live: https://rulcode.com
Arrays & Strings
- Two Pointers — Use two pointers to traverse arrays efficiently
- Sliding Window — Maintain a window of elements for efficient computation
- Prefix Sum — Pre-compute cumulative sums for range queries
- Binary Search — Search in sorted arrays in logarithmic time
- Kadane's Algorithm — Find maximum subarray sum efficiently
- Dutch National Flag — Sort array of three distinct elements
- Merge Intervals — Merge overlapping intervals
- Monotonic Stack — Stack with monotonic properties for efficient queries
- Rotate Array In-Place — Rotate array elements without extra space
- Cyclic Sort — Sort by placing elements at their correct index
Linked List
- Fast & Slow Pointers — Detect cycles and find middle using two pointers
- Reverse Linked List — Reverse a singly linked list
- Merge Two Sorted Lists — Merge two sorted linked lists
- Detect Cycle — Floyd's algorithm to detect cycles
- Middle Node — Find middle node using fast and slow pointers
Trees & BSTs
- DFS Preorder — Visit root, left, then right subtree
- DFS Inorder — Visit left, root, then right subtree
- DFS Postorder — Visit left, right, then root
- BFS Level Order — Traverse tree level by level
- BST Insert — Insert node in binary search tree
- Lowest Common Ancestor — Find LCA of two nodes in tree
- Recover BST — Fix BST with two swapped nodes
- Serialize Tree — Serialize and deserialize binary tree
- Trie (Prefix Tree) — Efficient string storage and retrieval
Graphs
- Graph DFS — Depth-first traversal of graphs
- Graph BFS — Breadth-first traversal of graphs
- Topological Sort — Kahn's algorithm for DAG ordering
- Union-Find — Disjoint set data structure
- Kruskal's Algorithm — Find minimum spanning tree
- Prim's Algorithm — Find MST using greedy approach
- Dijkstra's Algorithm — Single-source shortest path
- Bellman-Ford — Shortest path with negative weights
- Floyd-Warshall — All-pairs shortest paths
- A* Search — Heuristic pathfinding algorithm
Dynamic Programming
- 0/1 Knapsack — Maximize value with weight constraint
- Coin Change — Minimum coins for target amount
- Longest Common Subsequence — Find longest common subsequence
- Longest Increasing Subsequence — Find LIS in array
- Edit Distance — Minimum edits to transform strings
- Matrix Path DP — Find unique or minimum paths in matrix
- Partition Equal Subset — Check if array can be partitioned equally
- House Robber — Maximum sum without adjacent elements
- Climbing Stairs — Count ways to climb n stairs
- Word Break — Segment string into dictionary words
Greedy
- Activity Selection — Select maximum non-overlapping activities
- Interval Scheduling — Schedule intervals optimally
- Huffman Encoding — Optimal prefix-free encoding
- Gas Station — Find starting station for circular tour
Backtracking
- Subsets — Generate all subsets of a set
- Permutations — Generate all permutations
- Combinations — Generate all k-combinations
- Combination Sum — Find combinations summing to target
- Word Search — Find word in 2D grid
- N-Queens — Place N queens on N×N board
- Sudoku Solver — Solve Sudoku puzzle
Bit Manipulation
- XOR Trick — Find single number using XOR
- Count Bits — Brian Kernighan's algorithm
- Subset Generation with Bits — Generate subsets using bitmasks
Heap / Priority Queue
- Kth Largest Element — Find kth largest using min heap
- Merge K Sorted Lists — Merge using min heap
- Sliding Window Maximum — Find max in each window
Math & Number Theory
- GCD (Euclidean) — Euclid's algorithm for GCD
- Sieve of Eratosthenes — Generate all primes up to n
- Modular Exponentiation — Fast power with modulo
- Karatsuba Multiplication — Fast multiplication algorithm
Advanced
- Segment Tree — Range query data structure
- Fenwick Tree (BIT) — Binary indexed tree for prefix sums
- Sparse Table — Range minimum query in O(1)
- KMP String Matching — Linear time pattern matching
- Rabin-Karp — Rolling hash pattern matching
- Manacher's Algorithm — Longest palindromic substring
- Union by Rank + Path Compression — Optimized union-find
- Tarjan's Algorithm — Find strongly connected components
- Binary Lifting — LCA using binary lifting
// ...existing code...
Blind 75 Problems
-
Array & Hashing
- Two Sum — Find pair that sums to target
- Contains Duplicate — Check for duplicates in array
- Valid Anagram — Check if strings are anagrams
- Group Anagrams — Group strings by anagram
- Top K Frequent — Find k most frequent elements
- Product Except Self — Array product without division
- Encode Decode Strings — Encode/decode string array
- Longest Consecutive — Longest consecutive sequence
-
Two Pointers
- Valid Palindrome — Check if string is palindrome
- Three Sum — Find triplets that sum to zero
- Container With Most Water — Max water container area
-
Sliding Window
- Best Time to Buy Sell — Max profit from stock prices
- Longest Substring — Longest substring without repeating chars
- Longest Repeating — Longest repeating char replacement
- Minimum Window — Minimum window substring
-
Stack
- Valid Parentheses — Check valid bracket sequence
- Min Stack — Stack with constant time minimum
-
Binary Search
- Find Minimum in Rotated — Min in rotated sorted array
- Search in Rotated — Search in rotated sorted array
-
Trees
- Maximum Depth — Max depth of binary tree
- Same Tree — Check if trees are identical
- Invert Binary Tree — Mirror a binary tree
- Binary Tree Maximum Path — Max path sum in binary tree
- Binary Tree Level Order — Level order traversal
- Serialize Deserialize — Serialize/deserialize binary tree
- Subtree of Another — Check if tree is subtree
- Construct from Preorder — Build tree from traversal
-
Tries
- Implement Trie — Implement prefix tree
- Word Search II — Find words in board using trie
-
Heap / Priority Queue
- Find Median from Stream — Running median with heaps
-
Backtracking
- Combination Sum — Find combinations that sum to target
- Word Search — Find word in board
-
Graphs
- Number of Islands — Count islands in grid
- Clone Graph — Deep copy of graph
- Pacific Atlantic — Water flow between oceans
- Course Schedule — Course prerequisites graph
- Number of Connected — Count connected components
- Graph Valid Tree — Check if graph is valid tree
-
Dynamic Programming
- Climbing Stairs — Ways to climb n stairs
- House Robber — Max money without adjacent houses
- House Robber II — Circular house robber
- Longest Palindromic — Longest palindromic substring
- Unique Paths — Unique paths in grid
- Jump Game — Can reach last index
// ...existing code...
There are several ways of editing your application.
If you want to work locally using your own IDE, you can clone this repo and push changes.
Pushed changes will also be reflected in Lovable.
The only requirement is having Node.js & npm installed - install with nvm
Follow these steps:
# Step 1: Install dependencies
npm i
# Step 2: Start development server
npm run dev- Navigate to the desired file(s)
- Click the pencil ✏️ icon at top-right of the file
- Make your changes and commit
- Navigate to the main page of your repository
- Click on Code → Codespaces → New Codespace
- Edit files directly within the Codespace and commit when done
- ⚡ Next.js
- 💎 TypeScript
- ⚛️ React
- 🎨 shadcn/ui
- 💨 Tailwind CSS
We welcome contributions!
Help us expand Rulcode.com with more algorithms, better explanations, and improved visualizations.
Fork → Edit → Pull Request.
⭐ Star this repo if you find it helpful!