Practice how to think, not just how to code.
Browse the catalog and open the focused workspace for any problem. Each session walks you through clarifying questions, reasoning, optimization trade-offs, and follow-ups — with an AI coach beside you.
Two Sum
Find the two indices whose values add to a target.
Valid Anagram
Determine if one string is a permutation of another.
LRU Cache
Design a cache with O(1) get and put using LRU eviction.
Course Schedule
Detect a cycle in a directed dependency graph.
Word Break
Can a string be segmented into dictionary words?
Number of Islands
Count connected components of land in a grid.
Trapping Rain Water
How much water can be trapped between elevation bars?
Median of Two Sorted Arrays
Find the median of two sorted arrays in O(log(min(n, m))).
Best Time to Buy and Sell Stock
Find the maximum profit from a single buy-sell pair in a price series.
Maximum Subarray
Find the contiguous subarray with the largest sum (Kadane's algorithm).
Climbing Stairs
Count the distinct ways to reach the top of an n-step staircase.
Valid Parentheses
Decide whether a string of brackets is balanced.
Contains Duplicate
Detect whether any value appears more than once in an array.
Container With Most Water
Pick two vertical lines that, with the x-axis, hold the most water.
3Sum
Find all unique triplets in the array that sum to zero.
Longest Substring Without Repeating Characters
Find the length of the longest substring containing all unique characters.
Top K Frequent Elements
Return the k most frequent elements from an integer array.
Product of Array Except Self
Return an array where output[i] is the product of every other element.
Merge Intervals
Merge all overlapping intervals and return the sorted, merged result.
Search in Rotated Sorted Array
Find a target in a sorted array that has been rotated at an unknown pivot.
Coin Change
Find the fewest coins needed to make a target amount.
House Robber
Maximize loot from a row of houses where adjacent houses can't both be robbed.
Longest Palindromic Substring
Return the longest palindromic substring of s (expand-around-center).
Subsets
Generate all subsets (the power set) of a unique-integer array.
Decode Ways
Count how many ways a digit string can be decoded into letters A–Z.
Longest Increasing Subsequence
Find the length of the longest strictly increasing subsequence of nums.
Edit Distance
Compute the minimum insert/delete/replace ops to convert word1 into word2.
Sliding Window Maximum
Return the maximum of every window of size k as it slides over nums.
Reverse Linked List
Reverse a singly linked list in place and return the new head.
Invert Binary Tree
Mirror every node's left/right children and return the new root.
Longest Consecutive Sequence
Find the length of the longest run of consecutive integers in O(n).
Missing Number
Given nums in [0, n] with one missing, return the missing number.
Single Number
Find the one element that appears once in an array where every other appears twice.
Majority Element
Find the element that appears more than ⌊n/2⌋ times (Boyer-Moore vote).
Intersection of Two Arrays
Return unique values that appear in both arrays.
Move Zeroes
Move all 0s to the end while preserving the relative order of non-zero elements.
Valid Sudoku
Determine if a partially filled 9×9 Sudoku board is valid.
Happy Number
Decide whether the squares-of-digits process eventually reaches 1.
Isomorphic Strings
Decide whether s and t are isomorphic via a consistent character mapping.
Plus One
Increment a big integer represented as an array of digits.
Valid Palindrome
Decide if a string reads the same forwards and backwards (alphanumeric, case-insensitive).
Two Sum II — Input Array Is Sorted
Find two 1-indexed numbers in a sorted array that sum to target.
Sort Colors
Sort an array of 0/1/2 values in a single pass (Dutch national flag).
3Sum Closest
Return the sum of three integers closest to the target.
Squares of a Sorted Array
Square each element of a sorted array; return the result in non-decreasing order.
Is Subsequence
Decide whether s appears as a subsequence of t.
Backspace String Compare
Decide if two strings are equal after applying '#' as backspace.
Partition Labels
Split a string into the largest possible parts where every letter appears in only one part.
Boats to Save People
Pair the heaviest with the lightest; minimize boats given a weight limit.
Reverse String
Reverse a string.
Longest Repeating Character Replacement
Find the longest substring you can make uniform by changing at most k characters.
Permutation in String
Decide whether s2 contains any permutation of s1 as a substring.
Find All Anagrams in a String
Return all start indices of anagrams of p inside s.
Fruit Into Baskets
Longest contiguous subarray containing at most 2 distinct values.
Subarray Sum Equals K
Count contiguous subarrays whose sum equals k.
Minimum Size Subarray Sum
Smallest contiguous subarray with sum ≥ target (positives only).
Maximum Number of Vowels in a Substring of Given Length
Maximum vowels within any window of length k.
Longest Substring with At Most K Distinct Characters
Longest substring containing no more than k distinct characters.
Minimum Window Substring
Smallest window in s containing every character of t (with multiplicity).
Max Consecutive Ones
Length of the longest run of 1s in a binary array.
Evaluate Reverse Polish Notation
Evaluate an arithmetic expression in postfix (RPN) notation.
Daily Temperatures
For each day, find how many days until a warmer temperature.
Next Greater Element I
For each value in nums1, find its next greater value in nums2.
Next Greater Element II
Next greater element in a circular array.
Asteroid Collision
Simulate asteroid collisions; positives move right, negatives move left.
Simplify Path
Convert a Unix-style absolute path to its canonical form.
Decode String
Expand encoded strings of the form `k[encoded_string]`.
Remove K Digits
Remove k digits from a number string to make the smallest number.
Largest Rectangle in Histogram
Find the largest rectangle that fits within a histogram of bar heights.
Validate Stack Sequences
Check if a pop sequence is achievable from a push sequence using a stack.
Binary Search
Classic binary search on a sorted array.
Search a 2D Matrix
Search a row- and column-sorted matrix where row[i+1][0] > row[i][last].
Find Minimum in Rotated Sorted Array
Find the minimum in a rotated, otherwise-sorted array of unique values.
Search Insert Position
Return the index where target would be inserted in sorted nums.
Koko Eating Bananas
Find the minimum eating speed k that finishes all piles within h hours.
Capacity to Ship Packages Within D Days
Minimum ship capacity to deliver weights[] in order within `days` days.
Find First and Last Position of Element in Sorted Array
Return [first, last] indices of target in a sorted array, or [-1, -1].
Search a 2D Matrix II
Search in a matrix sorted by rows and columns (weaker invariant).
Sqrt(x)
Compute integer square root truncated toward zero.
Single Element in a Sorted Array
Find the unique element in a sorted array where every other appears twice.
Merge Two Sorted Lists
Merge two sorted linked lists into one sorted list.
Merge K Sorted Lists
Merge k sorted linked lists into one sorted list.
Remove Nth Node From End of List
Remove the nth node counting from the end of a linked list.
Add Two Numbers
Add two numbers represented as reverse-order linked lists.
Swap Nodes in Pairs
Swap every two adjacent nodes in a linked list.
Reorder List
Reorder L0→L1→…→Ln−1→Ln into L0→Ln→L1→Ln−1→L2→Ln−2→… in place.
Palindrome Linked List
Decide whether a linked list is a palindrome.
Middle of the Linked List
Return the second middle node (or the only middle for odd lengths).
Odd Even Linked List
Group nodes at odd positions before nodes at even positions (1-indexed).
Remove Duplicates from Sorted List
Delete all duplicates so each value appears at most once.
Partition List
Reorder so all nodes < x come before all nodes ≥ x, preserving relative order.
Rotate List
Rotate the list to the right by k places.
Reverse Linked List II
Reverse the nodes between positions left and right (1-indexed).
Reverse Nodes in K-Group
Reverse the nodes of the list k at a time; leave any remaining tail as-is.
Maximum Depth of Binary Tree
Return the depth of the deepest leaf in a binary tree.
Same Tree
Decide whether two binary trees are structurally and value-wise identical.
Symmetric Tree
Decide whether a binary tree is mirror-symmetric around its center.
Balanced Binary Tree
Decide whether a binary tree is height-balanced.
Diameter of Binary Tree
Length of the longest path between any two nodes in a tree.
Binary Tree Level Order Traversal
Return the values at each level (top to bottom).
Binary Tree Zigzag Level Order Traversal
Level order traversal where direction alternates per level.
Binary Tree Right Side View
Return the values of the rightmost node at each level.
Validate Binary Search Tree
Decide whether a binary tree is a strict BST.
Lowest Common Ancestor of a Binary Search Tree
Find the lowest common ancestor of two values in a BST (return the LCA node's value).
Lowest Common Ancestor of a Binary Tree
LCA in a generic binary tree (no BST property). Returns LCA node's value.
Kth Smallest Element in a BST
Return the k-th smallest element in a BST.
Path Sum
Decide whether some root-to-leaf path sums to target.
Binary Tree Maximum Path Sum
Maximum sum of any path between any two nodes (path may not pass through root).
Count Good Nodes in Binary Tree
Count nodes whose value is ≥ every value on the root-to-node path.
Binary Tree Preorder Traversal
Return the preorder traversal of a tree (root, left, right).
Binary Tree Inorder Traversal
Return the inorder traversal of a tree (left, root, right).
Binary Tree Postorder Traversal
Return the postorder traversal of a tree (left, right, root).
Replace Words
Replace each word in a sentence with its shortest dictionary root.
Longest Word in Dictionary through Deleting
Find the longest word in dictionary that can be formed by deleting characters of s.
Word Pattern
Decide whether a string follows a given pattern via bijective mapping.
Longest Common Prefix
Find the longest common prefix of an array of strings.
Longest Word in Dictionary
Longest word that can be built one char at a time from other words in the dictionary.
Kth Largest Element in an Array
Find the k-th largest value in an array.
Last Stone Weight
Simulate stone smashing using a max-heap; return the final stone's weight.
K Closest Points to Origin
Return the k points closest to (0,0) under Euclidean distance.
IPO
Pick at most k profitable projects under capital constraints.
Reorganize String
Rearrange characters so that no two adjacent characters are equal.
Minimum Cost to Connect Sticks
Repeatedly combine the two cheapest sticks; return total cost.
Furthest Building You Can Reach
Greedy: spend ladders on the largest jumps, bricks on smaller ones.
Find K Pairs with Smallest Sums
Return the k pairs with the smallest sums from two sorted arrays.
Car Pooling
Decide whether car capacity is enough across all trips.
Minimum Number of Refueling Stops
Greedy: always refuel at the largest unused station that is still reachable.
Meeting Rooms II
Minimum number of conference rooms to host all meetings.
Maximum Performance of a Team
Maximize sum(speed) × min(efficiency) for a team of at most k engineers.
Subsets II
Return all unique subsets of an array that may contain duplicates.
Permutations
Return all permutations of a unique-integer array.
Permutations II
Return all unique permutations when the input contains duplicates.
Combinations
Return all combinations of k numbers chosen from 1..n.
Combination Sum
All combinations from candidates that sum to target. Each candidate may be reused.
Combination Sum II
Each candidate may be used at most once; result must contain unique combinations.
Combination Sum III
Find k-element combinations from 1..9 summing to n.
Letter Combinations of a Phone Number
Return all letter combinations the digit string could represent (T9 keypad).
Generate Parentheses
Generate all combinations of n well-formed parentheses.
Word Search
Decide whether a word can be traced through adjacent cells in a board.
Restore IP Addresses
Return all valid IPv4 addresses formed by inserting dots into a digit string.
Max Area of Island
Largest 4-connected '1' region in a binary grid.
Flood Fill
Replace all 4-connected pixels of a region with a target color.
Rotting Oranges
Multi-source BFS for the time until all fresh oranges rot.
Pacific Atlantic Water Flow
Cells from which water can flow to both oceans.
Shortest Path in Binary Matrix
Shortest 8-connected path of zeros from top-left to bottom-right.
Course Schedule II
Return a valid order to take all courses or [] if impossible.
Number of Connected Components in an Undirected Graph
Count the number of connected components.
Graph Valid Tree
Decide whether an undirected graph is a tree (connected and acyclic).
Redundant Connection
Find the edge that, if removed, makes the graph a tree.
Word Ladder
Length of the shortest transformation sequence between two words.
Network Delay Time
Time for a signal sent from k to reach all nodes (Dijkstra).
Cheapest Flights Within K Stops
Cheapest path from src to dst using at most k stops (Bellman-Ford).
Min Cost to Connect All Points
Minimum spanning tree of points under Manhattan distance.
Swim in Rising Water
Minimum time to swim from top-left to bottom-right (Dijkstra on max edge).
Alien Dictionary
Infer the alphabet order from a list of words sorted in alien-language order.
Path With Minimum Effort
Path from top-left to bottom-right minimizing maximum height delta.
Number of Provinces
Count connected components from a friendship adjacency matrix.
Is Graph Bipartite?
Decide whether the given undirected graph is bipartite via 2-coloring.
Minimum Height Trees
Roots that minimize tree height — at most 2 valid centroids.
Find the Town Judge
Find the unique node trusted by everyone but trusts no one.
Keys and Rooms
Decide whether all rooms can be visited starting from room 0.
House Robber II
Houses arranged in a circle — adjacent houses cannot both be robbed.
Coin Change II
Number of distinct combinations of coins that sum to amount.
Partition Equal Subset Sum
Decide whether the array can be split into two equal-sum subsets.
Maximum Product Subarray
Largest contiguous-subarray product, accounting for negatives.
Min Cost Climbing Stairs
Minimum cost to reach the top, taking 1 or 2 steps at a time.
Target Sum
Number of ways to assign +/- signs to make the sum equal target.
Perfect Squares
Least number of perfect squares that sum to n.
Integer Break
Maximum product when breaking n into ≥ 2 positive integers.
Unique Paths
Number of paths from top-left to bottom-right moving only right or down.
Unique Paths II
Same as Unique Paths, but with obstacles blocking some cells.
Minimum Path Sum
Cheapest path from top-left to bottom-right (right/down only).
Longest Common Subsequence
Length of the longest subsequence common to two strings.
Distinct Subsequences
Number of distinct subsequences of s that equal t.
Interleaving String
Decide whether s3 is an interleaving of s1 and s2.
Longest Palindromic Subsequence
Length of the longest subsequence of s that is a palindrome.
Regular Expression Matching
Implement '.' and '*' regex matching against an input string.
Jump Game
Decide whether you can reach the last index from the first.
Jump Game II
Minimum number of jumps to reach the last index.
Gas Station
Find a starting station to complete the circuit, or -1 if impossible.
Hand of Straights
Decide whether the hand can be split into groups of consecutive cards.
Valid Parenthesis String
Decide whether the string with '(', ')', '*' wildcards is a valid balanced expression.
Candy
Distribute minimum candy so children with higher ratings get more than neighbors.
Task Scheduler
Minimum time to complete all tasks with cooldown constraint.
Queue Reconstruction by Height
Reconstruct queue from (height, k) pairs.
Insert Interval
Insert a new interval into a sorted, non-overlapping list and merge as needed.
Non-overlapping Intervals
Min number of intervals to remove so the rest are non-overlapping.
Minimum Number of Arrows to Burst Balloons
Min number of arrows to pop all balloons (intervals on a number line).
Meeting Rooms
Decide whether one person can attend every meeting (no overlaps).
Interval List Intersections
Intersection of two sorted, non-overlapping interval lists.
Video Stitching
Min number of clips needed to cover [0, time].
Maximum Length of Pair Chain
Longest chain of pairs (a, b) where each next pair starts after previous ends.
Summary Ranges
Compress a sorted unique int list into ranges like '0->2'.
Remove Covered Intervals
Count intervals after removing those fully covered by another interval.
Wiggle Subsequence
Length of the longest alternating-difference subsequence.
Pow(x, n)
Compute x raised to the integer power n in O(log |n|).
Count Primes
Count primes strictly less than n using the Sieve of Eratosthenes.
Multiply Strings
Multiply two non-negative integers represented as strings.
Add Binary
Add two binary strings and return the binary sum as a string.
Excel Sheet Column Number
Convert an Excel column title (A, B, ..., Z, AA, AB, ...) to its column number.
Excel Sheet Column Title
Convert an integer column number to its Excel-style title.
Roman to Integer
Convert a Roman numeral string to an integer.
Integer to Roman
Convert an integer in [1, 3999] to its Roman-numeral representation.
Number of 1 Bits
Count the number of '1' bits in a non-negative integer.
Counting Bits
Return an array where ans[i] = number of 1's in binary representation of i.
Hamming Distance
Number of bit positions where two integers differ.
Power of Two
Decide whether a positive integer is a power of two.
Power of Three
Decide whether n is a power of three.
Power of Four
Decide whether n is a power of four.
Find the Difference
Find the extra letter that appears in t but not in s.
Single Number II
Find the element that appears once when every other element appears thrice.
Fibonacci Number
Return the n-th Fibonacci number.
N-th Tribonacci Number
Return the n-th Tribonacci number (sum of previous three).
Ransom Note
Decide whether the magazine letters can construct the ransom note.
Ugly Number
Decide whether n's only prime factors are 2, 3, 5.
Ugly Number II
Find the n-th ugly number (only prime factors 2, 3, 5).
Arranging Coins
Largest k such that k(k+1)/2 ≤ n.
Valid Perfect Square
Decide whether n is a perfect square (without sqrt).
Add Digits
Repeatedly sum a number's digits until a single-digit number remains.
Monotonic Array
Decide whether the array is entirely non-decreasing or entirely non-increasing.
Find Pivot Index
Smallest index where left-sum equals right-sum.
Rotate String
Decide whether goal is a rotation of s.
Reverse Integer
Reverse digits of a 32-bit signed integer; return 0 on overflow.
Single Number III
Find the two numbers that appear once when every other number appears twice.
Number Complement
Flip every bit in the binary representation of n.
Base 7
Convert an integer to its base-7 string representation.
Valid Triangle Number
Count triplets that can form the sides of a triangle.
Maximum Sum of Subarrays of Size K
Largest sum among all contiguous subarrays of length k.
Maximum Points You Can Obtain From Cards
Pick exactly k cards from either end to maximize total points.
Maximum Sum of Distinct Subarrays With Length K
Largest k-window sum where every element is distinct.
Longest Valid Parentheses
Length of the longest substring of well-formed parentheses.
Find K Closest Elements
Return the k closest values to x, in ascending order.
Binary Tree Tilt
Sum of |left subtree sum − right subtree sum| over every node.
Path Sum II
Return all root-to-leaf paths whose values sum to the target.
Longest Univalue Path
Longest path (in edges) between any two nodes with equal values.
Binary Tree Level Order Sum
Return the sum of node values at each level (top-down).
Maximum Width of Binary Tree
Width of the widest level (counting null gaps between extremes).
Surrounded Regions
Capture every 'O' region not connected to the border by flipping to 'X'.
Minimum Knight Moves
Fewest knight moves from (0,0) to (x,y) on an infinite board.
01 Matrix
Distance from each cell to the nearest 0 in a binary matrix.
Bus Routes
Fewest buses to take to get from source to target.
Find the City With the Smallest Number of Neighbors at a Threshold Distance
City with fewest reachable cities within `distanceThreshold` (ties → largest id).
Maximal Square
Largest square sub-matrix containing only 1s; return its area.
Maximum Profit in Job Scheduling
Pick non-overlapping jobs to maximize total profit.
Paint House
Cheapest way to paint n houses with no two adjacent same color (3 colors).
Paint House II
Same as Paint House but with k colors — solve in O(n·k).
Minimum Window Subsequence
Smallest window in s of which t is a subsequence (preserving order).
Spiral Matrix
Return all elements of a matrix in spiral order.
Rotate Image
Rotate an n×n matrix 90° clockwise in place.
Set Matrix Zeroes
If an element is 0, set its entire row and column to 0 in place.
Count Vowel Substrings of a String
Count substrings consisting of only vowels and containing all five.
Implement Trie (Prefix Tree)
Design a trie supporting `insert`, `search`, and `startsWith` in O(L).
Find Median From Data Stream
Maintain the running median of a stream with O(log n) inserts and O(1) reads.