Step through hand-crafted, frame-by-frame visualizations. Watch pointers move, stacks grow, links flip, and code lines light up as the algorithm runs.
Given an integer array nums, return all unique triplets [a, b, c] (i ≠ j ≠ k) such that nums[i] + nums[j] + nums[k] = 0.
Add two binary strings, returning the binary sum.
Trie-based design supporting wildcard '.' queries.
Add two non-negative integers represented as reversed linked lists.
Return the average value of nodes on each level of a binary tree.
Implement a basic calculator supporting +, -, parentheses, and spaces.
You are given an array prices where prices[i] is the stock price on day i. Choose one day to buy and a later day to sell. Return the maximum profit you can make, or 0 if no profit is possible.
Buy and sell as many times as you like to maximize profit.
Maximise profit with at most two non-overlapping buy-sell transactions.
Maximise profit with at most k non-overlapping buy-sell transactions.
Search for a target value within a sorted array. Continually halve the search interval by comparing the midpoint element, achieving O(log N) search speed.
Given the root of a binary tree, return the inorder traversal of its node values (Left → Root → Right). Solve iteratively using an explicit stack — O(N) time, O(H) auxiliary space where H is the tree height.
Return the values level by level using BFS.
Maximum-sum simple path that may pass through any node of a binary tree.
Return the values you'd see standing on the right side of a binary tree.
Level-order traversal but alternate left-to-right and right-to-left.
Compute the bitwise AND of every integer in an inclusive range.
Design an inorder iterator over a BST with O(h) memory.
Hand out minimum candies so neighbours with higher ratings get strictly more.
You are climbing a staircase that takes n steps. Each time you can climb 1 or 2 steps. Count the distinct ways to reach the top.
Deep-copy an undirected graph using a hashmap of original→clone.
Fewest coins needed to make a target amount, or -1 if impossible.
Find every combination of candidates (with reuse) that sums to target.
Generate every k-sized combination of integers from 1..n.
Build a quad tree representation of an n×n binary grid.
Reconstruct a binary tree given its inorder and postorder traversals.
Reconstruct a binary tree given its preorder and inorder traversals.
Pick two vertical lines so the rectangle they form with the x-axis holds the most water.
Decide whether there are two equal elements within k indices of each other.
Deep-copy a linked list whose nodes carry an additional random pointer.
Count every node in a complete binary tree in better than O(n) time.
Decide whether you can finish all courses given prerequisite pairs (cycle detection).
Return any valid course order, or empty if it's impossible.
Minimum insertions/deletions/substitutions to transform one string into another.
Answer division queries from a list of A/B = k equations using a graph.
Evaluate an arithmetic expression written in postfix notation using a stack.
Count the trailing zeroes in n! using the factors of 5.
Find the leftmost and rightmost indices of a target value.
Return the first index of `needle` in `haystack`, or -1 if not found.
Find the k pairs (one from each sorted array) with the smallest sums.
Track the running median of a stream using two heaps.
Find the smallest element of a rotated sorted array.
Find any index whose value is strictly greater than its neighbours in O(log n).
Flatten a binary tree into a right-only linked list following preorder.
Compute the next generation of Conway's Game of Life in place.
Find the starting gas station that lets you complete the loop, or report failure.
Generate every well-formed parenthesis string of length 2n.
Given an array of strings strs, group the anagrams together. Two strings are anagrams if they contain the same characters with the same counts.
Compute the largest h such that the researcher has ≥ h papers with ≥ h citations.
Decide whether iterating the digit-squared-sum reaches 1 (happy) or cycles.
Maximise money robbed without robbing adjacent houses.
Implement insert, search, and startsWith on a prefix tree.
Design a set with O(1) insert, remove, and uniform random access.
Insert a new interval into a sorted non-overlapping list and merge as needed.
Convert an integer to its Roman numeral string representation.
Decide whether s3 is formed by interleaving the characters of s1 and s2.
Swap left and right children of every node in a binary tree.
Pick up to k projects maximising final capital using two heaps.
Decide whether one string is a (not necessarily contiguous) subsequence of another.
Decide whether two strings have the same character-to-character mapping.
Each cell holds a max jump; decide whether you can reach the last index.
Same as Jump Game but return the minimum number of jumps to reach the end.
Find the k-th largest element with a min-heap or quickselect.
Return the k-th smallest value in a BST using inorder traversal.
Find the length of the last word in a space-separated sentence.
Enumerate every letter combo from a digit string (T9 keypad).
Given the head of a singly linked list, decide whether it contains a cycle. Solve it in O(1) extra memory using Floyd's tortoise & hare.
Return the longest common prefix shared by every string in the input.
Find the length of the longest run of consecutive integers in O(n) time.
Length of the longest strictly increasing subsequence.
Return the longest substring that reads the same forwards and backwards.
Given a string s, find the length of the longest substring with no repeated characters.
Find the lowest node that is an ancestor of two given nodes.
Design an LRU cache with O(1) get and put using a doubly linked list + hashmap.
Find the element that appears more than n/2 times. Boyer-Moore vote in O(1) space.
Largest square of '1's in a 2D binary matrix.
Given the root of a binary tree, return its maximum depth — the number of nodes along the longest path from the root down to the farthest leaf.
Given an integer array nums, find the contiguous non-empty subarray with the largest sum and return that sum.
Same as Maximum Subarray but the array wraps around.
Median of two sorted arrays in O(log(min(m,n))).
Merge overlapping intervals after sorting by start.
Merge k sorted linked lists into a single sorted list.
Given two sorted integer arrays nums1 (with size m + n, last n slots empty) and nums2 (size n), merge nums2 into nums1 as one sorted array. Must work in place.
Given the heads of two sorted singly linked lists, merge them into a single sorted list by splicing nodes (no extra storage). Return the head of the merged list.
Find the fewest vertical arrows that pop every interval-shaped balloon.
Find the smallest contiguous subarray whose sum is ≥ target.
Design a stack that supports push/pop/top/getMin all in O(1).
Find the minimum absolute difference between any two values in a BST.
Find the fewest single-character mutations between two gene strings.
Minimum-sum path from top-left to bottom-right of a grid moving right/down.
Find the shortest window in `s` that contains every character of `t`.
Count the number of ways to place n non-attacking queens on an n×n board.
Count the number of set bits in a 32-bit unsigned integer.
Given an m × n grid of '1' (land) and '0' (water), count the number of islands. An island is a maximal connected group of land cells (horizontal/vertical neighbours).
Decide whether an integer reads the same forwards and backwards.
Reorder a linked list so all nodes < x come before nodes ≥ x, preserving order.
Decide whether some root-to-leaf path sums exactly to a target.
Generate every permutation of an integer array using backtracking.
Add one to an integer represented as a digit array.
Wire each node's `next` pointer to the node immediately to its right.
Implement x^n using fast (binary) exponentiation.
Return an array where each entry is the product of every other element — no division.
Decide whether the letters of a magazine can spell a ransom note.
Compact a sorted array so each element appears once; return the new length.
Same as above but each element may appear at most twice.
Delete every node that has a duplicate from a sorted linked list.
Remove every occurrence of a value from an array in place; return the new length.
Remove the n-th node from the end using a single-pass gap of two pointers.
Reverse the bits of a 32-bit unsigned integer.
Reverse only the nodes between positions left and right of a linked list.
Given the head of a singly linked list, reverse the list, and return the reversed list. Reverse the directional pointer links iteratively in-place utilizing O(1) space complexity constraints.
Reverse the nodes of a linked list in groups of size k.
Reverse the order of words in a string, collapsing extra whitespace.
Convert a Roman numeral string to its integer value.
Rotate an array to the right by k steps in O(1) extra space.
Rotate an n×n matrix 90° clockwise in place.
Rotate a linked list to the right by k places.
Decide whether two binary trees are structurally identical with matching values.
Treat a row-sorted matrix as a flat sorted array and binary search it.
Given a sorted array of distinct integers and a target value, return the index where the target is found. If not, return the index where it would be inserted in order. Must run in O(log N) time.
Binary search a sorted array that has been rotated at an unknown pivot.
Whenever a cell is 0, zero out its entire row and column — ideally O(1) extra space.
Canonicalize a Unix-style path using a stack of directory names.
Every element appears twice except one — find it in O(1) extra space.
Every element appears three times except one — find it.
Find the minimum number of dice rolls to reach the last square via BFS.
Sort a linked list in O(n log n) time using merge sort.
Build a height-balanced BST from a sorted array using the middle as the root.
Traverse a 2D matrix in spiral order and return the visited values.
Integer square root of a non-negative integer.
Find every starting index whose substring is a concatenation of all given words.
Sum every integer represented by a root-to-leaf digit path.
Collapse a sorted unique integer array into a list of inclusive range strings.
Capture every region of 'O' cells that is fully enclosed by 'X'.
Decide whether a binary tree is a mirror image of itself around its center.
Fully justify lines of text to a fixed character width.
Compute how much rainwater can be trapped between bars of an elevation map.
Minimum top-to-bottom path sum in a triangle of integers.
Given an array of integers nums and an integer target, return the indices of the two numbers whose sum equals target. Each input has exactly one solution; you may not reuse the same element.
Given a 1-indexed sorted array of integers, find two numbers such that they add up to a specific target number. Return indices of the two elements. The algorithm must use O(1) additional space with two pointers moving inward.
Count grid paths avoiding obstacles, moving right/down.
Decide whether two strings are anagrams of each other.
A phrase is a palindrome if, after converting to lowercase and removing non-alphanumeric characters, it reads the same forwards and backwards. Decide if the input is a palindrome.
Determine if an input string containing the brackets "(", ")", "{", "}", "[" and "]" is valid. Parentheses must close in highly ordered matching bounds, using a Stack structure to verify nested layers.
Decide if a partially filled Sudoku board violates any row, column, or 3×3 box rule.
Given the root of a binary tree, decide whether it satisfies the BST property: every node in the left subtree is strictly less than the node, and every node in the right subtree is strictly greater.
Can the string be segmented into words from a dictionary?
Find the shortest transformation chain between two words from a dictionary.
Decide whether a string of words follows a given letter pattern.
Decide whether a word can be traced on a 2D character grid.
Find every dictionary word that can be spelled by walking the grid (Trie + DFS).
Write a string in zigzag rows and read it back row by row.