Master Data Structures & Algorithms through interactive, visual games. Learn by playing, not just reading.
Navigate through an array building prefix sums step by step. Answer range-sum queries using prefix[L..R] formula.
Click L and R to perform range queries. See instant highlighting and learn prefix[R] - prefix[L-1] formula.
Apply range-update spells using difference arrays. Watch how +val at L and -val at R+1 creates magic!
Travel left to right maintaining max-so-far. Visualize the running maximum as you traverse.
Move from right to left computing suffix maximum. Essential for trapping-water problems!
Use leftMax and rightMax to calculate trapped water. Formula: min(leftMax[i], rightMax[i]) - height[i]
Carry forward variables as you traverse. Update freq, count, or max based on conditions.
Select start and end indices. Learn what makes a valid contiguous subarray!
Print all subarrays by iterating S and E. Watch every subarray appear visually!
Display each subarray with its sum. Compare nested-loop vs prefix-sum optimization!
Learn the contribution technique: arr[i] × (i+1) × (n-i). Visualize left & right choices!
Slide a window of size K. Drop left, add right. Compare brute-force vs sliding window!
Two pointers i and j that expand/contract. Learn acquire and release operations!
Click cells to see (row, col). Explore all corner indices and navigation patterns.
Trace top row → right column → bottom row → left column. Master boundary traversal!
Watch shrinking boundaries: top++, right--, bottom--, left++. Print elements in spiral!
Select TL and BR corners. See all valid submatrices, count them, compute sums!
Count pairs where char[i]='a' and char[j]='g'. Compare brute-force vs carry-forward!
Find leaders: arr[i] > max-left-so-far. Highlight leader positions as you traverse!
Choose buy-day and sell-day. Track minPriceSoFar and maxProfit for best trade!
Find where leftSum == rightSum. Visualize prefix & suffix sums at each index!
Use prefix array of even-count. Answer queries with pref[R] - pref[L-1]!
Explore sum(n) = n + sum(n-1). Watch the recursion tree expand with base case!
Visualize fact(n) = n × fact(n-1). Explore stack frames as recursion unfolds!
Draw the recursion tree. See exponential growth & learn DP/memoization alternative!
Fast exponentiation: half = pow(a, n/2), ans = half×half. O(n) vs O(log n)!
Input recurrences like T(n)=T(n-1)+k. Visualize recursion tree & final complexity!
Step through recursive calls. Watch push and pop operations on the call stack!
Solve various subarray problems: largest positive sum, even/odd properties, K-subarrays!
Build frequency maps. Count occurrences of each element in the array!
Sliding window with frequency map. Keep ≤ K distinct elements in window!
Difference array for range updates. Apply +val updates and get final array via prefix sum!
Use deque to maintain max/min in sliding window. Optimal O(n) solution!
Compute prefix and suffix product arrays. Solve product-array puzzles elegantly!
Advanced water trapping with prefixMax and suffixMax. Build and fill basins!
Ultimate combo: Triplet sum, pair difference, constrained subarrays, leaders, stocks, peaks!