æ
The Algorithm Laboratory
Request
Problem Catalog

Visualize a data-structures & algorithms problem.

Step through hand-crafted, frame-by-frame visualizations. Watch pointers move, stacks grow, links flip, and code lines light up as the algorithm runs.

||
152 of 152 problems
#15 · Arrays
Medium

3Sum

Given an integer array nums, return all unique triplets [a, b, c] (i ≠ j ≠ k) such that nums[i] + nums[j] + nums[k] = 0.

arraytwo-pointersorting
Time O(N²) · Space O(1)Visualize →
#67 · Math
Coming SoonEasy

Add Binary

Add two binary strings, returning the binary sum.

bit-manipulationstring
Visualization in progressPreview →
#211 · Tree
Coming SoonMedium

Design Add and Search Words Data Structure

Trie-based design supporting wildcard '.' queries.

triedesign
Visualization in progressPreview →
#2 · Linked List
Coming SoonMedium

Add Two Numbers

Add two non-negative integers represented as reversed linked lists.

linked-listmath
Visualization in progressPreview →
#637 · Tree
Coming SoonEasy

Average of Levels in Binary Tree

Return the average value of nodes on each level of a binary tree.

treebfs
Visualization in progressPreview →
#224 · Stack
Coming SoonHard

Basic Calculator

Implement a basic calculator supporting +, -, parentheses, and spaces.

stackstringmath
Visualization in progressPreview →
#121 · Arrays
Easy

Best Time to Buy and Sell Stock

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.

arraydp
Time O(N) · Space O(1)Visualize →
#122 · Arrays
Coming SoonMedium

Best Time to Buy and Sell Stock II

Buy and sell as many times as you like to maximize profit.

arraygreedy
Visualization in progressPreview →
#123 · Dynamic Programming
Coming SoonHard

Best Time to Buy and Sell Stock III

Maximise profit with at most two non-overlapping buy-sell transactions.

dp
Visualization in progressPreview →
#188 · Dynamic Programming
Coming SoonHard

Best Time to Buy and Sell Stock IV

Maximise profit with at most k non-overlapping buy-sell transactions.

dp
Visualization in progressPreview →
Searching
Easy

Binary Search (Sorted Array)

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.

binary-searchdivide-and-conquer
Time O(log N) · Space O(1)Visualize →
Tree
Medium

Binary Tree Inorder Traversal (Iterative)

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.

binary-treestackdfs
Time O(N) · Space O(H)Visualize →
#102 · Tree
Coming SoonMedium

Binary Tree Level Order Traversal

Return the values level by level using BFS.

treebfs
Visualization in progressPreview →
#124 · Tree
Coming SoonHard

Binary Tree Maximum Path Sum

Maximum-sum simple path that may pass through any node of a binary tree.

treedfs
Visualization in progressPreview →
#199 · Tree
Coming SoonMedium

Binary Tree Right Side View

Return the values you'd see standing on the right side of a binary tree.

treebfs
Visualization in progressPreview →
#103 · Tree
Coming SoonMedium

Binary Tree Zigzag Level Order Traversal

Level-order traversal but alternate left-to-right and right-to-left.

treebfs
Visualization in progressPreview →
#201 · Math
Coming SoonMedium

Bitwise AND of Numbers Range

Compute the bitwise AND of every integer in an inclusive range.

bit-manipulation
Visualization in progressPreview →
#173 · Tree
Coming SoonMedium

Binary Search Tree Iterator

Design an inorder iterator over a BST with O(h) memory.

treestackdesign
Visualization in progressPreview →
#135 · Arrays
Coming SoonHard

Candy

Hand out minimum candies so neighbours with higher ratings get strictly more.

arraygreedy
Visualization in progressPreview →
#70 · Dynamic Programming
Easy

Climbing Stairs

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.

dpfibonacci
Time O(N) · Space O(1)Visualize →
#133 · Graph
Coming SoonMedium

Clone Graph

Deep-copy an undirected graph using a hashmap of original→clone.

graphdfshashmap
Visualization in progressPreview →
#322 · Dynamic Programming
Coming SoonMedium

Coin Change

Fewest coins needed to make a target amount, or -1 if impossible.

dp
Visualization in progressPreview →
#39 · Backtracking
Coming SoonMedium

Combination Sum

Find every combination of candidates (with reuse) that sums to target.

backtracking
Visualization in progressPreview →
#77 · Backtracking
Coming SoonMedium

Combinations

Generate every k-sized combination of integers from 1..n.

backtracking
Visualization in progressPreview →
#427 · Tree
Coming SoonMedium

Construct Quad Tree

Build a quad tree representation of an n×n binary grid.

treedivide-and-conquer
Visualization in progressPreview →
#106 · Tree
Coming SoonMedium

Construct Binary Tree from Inorder and Postorder Traversal

Reconstruct a binary tree given its inorder and postorder traversals.

treerecursion
Visualization in progressPreview →
#105 · Tree
Coming SoonMedium

Construct Binary Tree from Preorder and Inorder Traversal

Reconstruct a binary tree given its preorder and inorder traversals.

treerecursion
Visualization in progressPreview →
#11 · Arrays
Coming SoonMedium

Container With Most Water

Pick two vertical lines so the rectangle they form with the x-axis holds the most water.

arraytwo-pointer
Visualization in progressPreview →
#219 · Hash Map
Coming SoonEasy

Contains Duplicate II

Decide whether there are two equal elements within k indices of each other.

hashmaparray
Visualization in progressPreview →
#138 · Linked List
Coming SoonMedium

Copy List with Random Pointer

Deep-copy a linked list whose nodes carry an additional random pointer.

linked-listhashmap
Visualization in progressPreview →
#222 · Tree
Coming SoonEasy

Count Complete Tree Nodes

Count every node in a complete binary tree in better than O(n) time.

treebinary-search
Visualization in progressPreview →
#207 · Graph
Coming SoonMedium

Course Schedule

Decide whether you can finish all courses given prerequisite pairs (cycle detection).

graphtopological-sort
Visualization in progressPreview →
#210 · Graph
Coming SoonMedium

Course Schedule II

Return any valid course order, or empty if it's impossible.

graphtopological-sort
Visualization in progressPreview →
#72 · Dynamic Programming
Coming SoonMedium

Edit Distance

Minimum insertions/deletions/substitutions to transform one string into another.

dpstring
Visualization in progressPreview →
#399 · Graph
Coming SoonMedium

Evaluate Division

Answer division queries from a list of A/B = k equations using a graph.

graphdfsunion-find
Visualization in progressPreview →
#150 · Stack
Coming SoonMedium

Evaluate Reverse Polish Notation

Evaluate an arithmetic expression written in postfix notation using a stack.

stackmath
Visualization in progressPreview →
#172 · Math
Coming SoonMedium

Factorial Trailing Zeroes

Count the trailing zeroes in n! using the factors of 5.

math
Visualization in progressPreview →
#34 · Searching
Coming SoonMedium

Find First and Last Position of Element in Sorted Array

Find the leftmost and rightmost indices of a target value.

binary-search
Visualization in progressPreview →
#28 · String
Coming SoonEasy

Find the Index of the First Occurrence in a String

Return the first index of `needle` in `haystack`, or -1 if not found.

stringtwo-pointer
Visualization in progressPreview →
#373 · Arrays
Coming SoonMedium

Find K Pairs with Smallest Sums

Find the k pairs (one from each sorted array) with the smallest sums.

heap
Visualization in progressPreview →
#295 · Arrays
Coming SoonHard

Find Median from Data Stream

Track the running median of a stream using two heaps.

heapdesign
Visualization in progressPreview →
#153 · Searching
Coming SoonMedium

Find Minimum in Rotated Sorted Array

Find the smallest element of a rotated sorted array.

binary-search
Visualization in progressPreview →
#162 · Searching
Coming SoonMedium

Find Peak Element

Find any index whose value is strictly greater than its neighbours in O(log n).

binary-search
Visualization in progressPreview →
#114 · Tree
Coming SoonMedium

Flatten Binary Tree to Linked List

Flatten a binary tree into a right-only linked list following preorder.

treedfs
Visualization in progressPreview →
#289 · Arrays
Coming SoonMedium

Game of Life

Compute the next generation of Conway's Game of Life in place.

matrixsimulation
Visualization in progressPreview →
#134 · Arrays
Coming SoonMedium

Gas Station

Find the starting gas station that lets you complete the loop, or report failure.

arraygreedy
Visualization in progressPreview →
#22 · Backtracking
Coming SoonMedium

Generate Parentheses

Generate every well-formed parenthesis string of length 2n.

backtrackingstring
Visualization in progressPreview →
#49 · Hash Map
Medium

Group Anagrams

Given an array of strings strs, group the anagrams together. Two strings are anagrams if they contain the same characters with the same counts.

hashmapstringsorting
Time O(N · K log K) · Space O(N · K)Visualize →
#274 · Arrays
Coming SoonMedium

H-Index

Compute the largest h such that the researcher has ≥ h papers with ≥ h citations.

arraysortingcounting
Visualization in progressPreview →
#202 · Hash Map
Coming SoonEasy

Happy Number

Decide whether iterating the digit-squared-sum reaches 1 (happy) or cycles.

hashmapmathcycle
Visualization in progressPreview →
#198 · Dynamic Programming
Coming SoonMedium

House Robber

Maximise money robbed without robbing adjacent houses.

dp
Visualization in progressPreview →
#208 · Tree
Coming SoonMedium

Implement Trie (Prefix Tree)

Implement insert, search, and startsWith on a prefix tree.

triedesign
Visualization in progressPreview →
#380 · Hash Map
Coming SoonMedium

Insert Delete GetRandom O(1)

Design a set with O(1) insert, remove, and uniform random access.

hashmaparraydesign
Visualization in progressPreview →
#57 · Arrays
Coming SoonMedium

Insert Interval

Insert a new interval into a sorted non-overlapping list and merge as needed.

intervals
Visualization in progressPreview →
#12 · String
Coming SoonMedium

Integer to Roman

Convert an integer to its Roman numeral string representation.

stringgreedy
Visualization in progressPreview →
#97 · Dynamic Programming
Coming SoonMedium

Interleaving String

Decide whether s3 is formed by interleaving the characters of s1 and s2.

dpstring
Visualization in progressPreview →
#226 · Tree
Coming SoonEasy

Invert Binary Tree

Swap left and right children of every node in a binary tree.

treedfs
Visualization in progressPreview →
#502 · Arrays
Coming SoonHard

IPO

Pick up to k projects maximising final capital using two heaps.

heapgreedy
Visualization in progressPreview →
#392 · String
Coming SoonEasy

Is Subsequence

Decide whether one string is a (not necessarily contiguous) subsequence of another.

stringtwo-pointer
Visualization in progressPreview →
#205 · Hash Map
Coming SoonEasy

Isomorphic Strings

Decide whether two strings have the same character-to-character mapping.

hashmapstring
Visualization in progressPreview →
#55 · Arrays
Coming SoonMedium

Jump Game

Each cell holds a max jump; decide whether you can reach the last index.

arraygreedy
Visualization in progressPreview →
#45 · Arrays
Coming SoonMedium

Jump Game II

Same as Jump Game but return the minimum number of jumps to reach the end.

arraygreedy
Visualization in progressPreview →
#215 · Arrays
Coming SoonMedium

Kth Largest Element in an Array

Find the k-th largest element with a min-heap or quickselect.

heapquickselect
Visualization in progressPreview →
#230 · Tree
Coming SoonMedium

Kth Smallest Element in a BST

Return the k-th smallest value in a BST using inorder traversal.

treebstinorder
Visualization in progressPreview →
#58 · String
Coming SoonEasy

Length of Last Word

Find the length of the last word in a space-separated sentence.

string
Visualization in progressPreview →
#17 · Backtracking
Coming SoonMedium

Letter Combinations of a Phone Number

Enumerate every letter combo from a digit string (T9 keypad).

backtrackingstring
Visualization in progressPreview →
#141 · Linked List
Easy

Linked List Cycle

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.

linked-listtwo-pointerfloyd
Time O(N) · Space O(1)Visualize →
#14 · String
Coming SoonEasy

Longest Common Prefix

Return the longest common prefix shared by every string in the input.

string
Visualization in progressPreview →
#128 · Hash Map
Coming SoonMedium

Longest Consecutive Sequence

Find the length of the longest run of consecutive integers in O(n) time.

hashmaparray
Visualization in progressPreview →
#300 · Dynamic Programming
Coming SoonMedium

Longest Increasing Subsequence

Length of the longest strictly increasing subsequence.

dpbinary-search
Visualization in progressPreview →
#5 · Dynamic Programming
Coming SoonMedium

Longest Palindromic Substring

Return the longest substring that reads the same forwards and backwards.

dpstring
Visualization in progressPreview →
#3 · String
Medium

Longest Substring Without Repeating Characters

Given a string s, find the length of the longest substring with no repeated characters.

stringsliding-windowhashmap
Time O(N) · Space O(min(N, charset))Visualize →
#236 · Tree
Coming SoonMedium

Lowest Common Ancestor of a Binary Tree

Find the lowest node that is an ancestor of two given nodes.

treedfs
Visualization in progressPreview →
#146 · Linked List
Coming SoonMedium

LRU Cache

Design an LRU cache with O(1) get and put using a doubly linked list + hashmap.

linked-listhashmapdesign
Visualization in progressPreview →
#169 · Arrays
Coming SoonEasy

Majority Element

Find the element that appears more than n/2 times. Boyer-Moore vote in O(1) space.

arrayboyer-moore
Visualization in progressPreview →
#221 · Dynamic Programming
Coming SoonMedium

Maximal Square

Largest square of '1's in a 2D binary matrix.

dpmatrix
Visualization in progressPreview →
#104 · Tree
Easy

Maximum Depth of Binary Tree

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.

treedfsrecursion
Time O(N) · Space O(H)Visualize →
#53 · Arrays
Medium

Maximum Subarray

Given an integer array nums, find the contiguous non-empty subarray with the largest sum and return that sum.

arraydpkadane
Time O(N) · Space O(1)Visualize →
#918 · Arrays
Coming SoonMedium

Maximum Sum Circular Subarray

Same as Maximum Subarray but the array wraps around.

arraydpkadane
Visualization in progressPreview →
#4 · Searching
Coming SoonHard

Median of Two Sorted Arrays

Median of two sorted arrays in O(log(min(m,n))).

binary-search
Visualization in progressPreview →
#56 · Arrays
Coming SoonMedium

Merge Intervals

Merge overlapping intervals after sorting by start.

intervalssorting
Visualization in progressPreview →
#23 · Linked List
Coming SoonHard

Merge k Sorted Lists

Merge k sorted linked lists into a single sorted list.

linked-listheapdivide-and-conquer
Visualization in progressPreview →
#88 · Arrays
Easy

Merge Sorted Array

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.

arraytwo-pointer
Time O(M + N) · Space O(1)Visualize →
#21 · Linked List
Easy

Merge Two Sorted Lists

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.

linked-list
Time O(M + N) · Space O(1)Visualize →
#452 · Arrays
Coming SoonMedium

Minimum Number of Arrows to Burst Balloons

Find the fewest vertical arrows that pop every interval-shaped balloon.

intervalsgreedy
Visualization in progressPreview →
#209 · Arrays
Coming SoonMedium

Minimum Size Subarray Sum

Find the smallest contiguous subarray whose sum is ≥ target.

arraysliding-window
Visualization in progressPreview →
#155 · Stack
Coming SoonMedium

Min Stack

Design a stack that supports push/pop/top/getMin all in O(1).

stackdesign
Visualization in progressPreview →
#530 · Tree
Coming SoonEasy

Minimum Absolute Difference in BST

Find the minimum absolute difference between any two values in a BST.

treebstinorder
Visualization in progressPreview →
#433 · Graph
Coming SoonMedium

Minimum Genetic Mutation

Find the fewest single-character mutations between two gene strings.

bfsstring
Visualization in progressPreview →
#64 · Dynamic Programming
Coming SoonMedium

Minimum Path Sum

Minimum-sum path from top-left to bottom-right of a grid moving right/down.

dpmatrix
Visualization in progressPreview →
#76 · String
Coming SoonHard

Minimum Window Substring

Find the shortest window in `s` that contains every character of `t`.

stringsliding-windowhashmap
Visualization in progressPreview →
#52 · Backtracking
Coming SoonHard

N-Queens II

Count the number of ways to place n non-attacking queens on an n×n board.

backtracking
Visualization in progressPreview →
#191 · Math
Coming SoonEasy

Number of 1 Bits

Count the number of set bits in a 32-bit unsigned integer.

bit-manipulation
Visualization in progressPreview →
#200 · Graph
Medium

Number of Islands

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).

matrixdfsflood-fill
Time O(M · N) · Space O(M · N)Visualize →
#9 · Math
Coming SoonEasy

Palindrome Number

Decide whether an integer reads the same forwards and backwards.

math
Visualization in progressPreview →
#86 · Linked List
Coming SoonMedium

Partition List

Reorder a linked list so all nodes < x come before nodes ≥ x, preserving order.

linked-listtwo-pointer
Visualization in progressPreview →
#112 · Tree
Coming SoonEasy

Path Sum

Decide whether some root-to-leaf path sums exactly to a target.

treedfs
Visualization in progressPreview →
#46 · Backtracking
Coming SoonMedium

Permutations

Generate every permutation of an integer array using backtracking.

backtracking
Visualization in progressPreview →
#66 · Math
Coming SoonEasy

Plus One

Add one to an integer represented as a digit array.

matharray
Visualization in progressPreview →
#117 · Tree
Coming SoonMedium

Populating Next Right Pointers in Each Node II

Wire each node's `next` pointer to the node immediately to its right.

treebfs
Visualization in progressPreview →
#50 · Math
Coming SoonMedium

Pow(x, n)

Implement x^n using fast (binary) exponentiation.

mathrecursion
Visualization in progressPreview →
#238 · Arrays
Coming SoonMedium

Product of Array Except Self

Return an array where each entry is the product of every other element — no division.

arrayprefix-product
Visualization in progressPreview →
#383 · Hash Map
Coming SoonEasy

Ransom Note

Decide whether the letters of a magazine can spell a ransom note.

hashmapstring
Visualization in progressPreview →
#26 · Arrays
Coming SoonEasy

Remove Duplicates from Sorted Array

Compact a sorted array so each element appears once; return the new length.

arraytwo-pointer
Visualization in progressPreview →
#80 · Arrays
Coming SoonMedium

Remove Duplicates from Sorted Array II

Same as above but each element may appear at most twice.

arraytwo-pointer
Visualization in progressPreview →
#82 · Linked List
Coming SoonMedium

Remove Duplicates from Sorted List II

Delete every node that has a duplicate from a sorted linked list.

linked-list
Visualization in progressPreview →
#27 · Arrays
Coming SoonEasy

Remove Element

Remove every occurrence of a value from an array in place; return the new length.

arraytwo-pointer
Visualization in progressPreview →
#19 · Linked List
Coming SoonMedium

Remove Nth Node From End of List

Remove the n-th node from the end using a single-pass gap of two pointers.

linked-listtwo-pointer
Visualization in progressPreview →
#190 · Math
Coming SoonEasy

Reverse Bits

Reverse the bits of a 32-bit unsigned integer.

bit-manipulation
Visualization in progressPreview →
#92 · Linked List
Coming SoonMedium

Reverse Linked List II

Reverse only the nodes between positions left and right of a linked list.

linked-list
Visualization in progressPreview →
Linked List
Medium

Reverse 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.

linked-listpointersiterative
Time O(N) · Space O(1)Visualize →
#25 · Linked List
Coming SoonHard

Reverse Nodes in k-Group

Reverse the nodes of a linked list in groups of size k.

linked-listrecursion
Visualization in progressPreview →
#151 · String
Coming SoonMedium

Reverse Words in a String

Reverse the order of words in a string, collapsing extra whitespace.

stringtwo-pointer
Visualization in progressPreview →
#13 · String
Coming SoonEasy

Roman to Integer

Convert a Roman numeral string to its integer value.

stringhashmap
Visualization in progressPreview →
#189 · Arrays
Coming SoonMedium

Rotate Array

Rotate an array to the right by k steps in O(1) extra space.

arrayreverse
Visualization in progressPreview →
#48 · Arrays
Coming SoonMedium

Rotate Image

Rotate an n×n matrix 90° clockwise in place.

matrix
Visualization in progressPreview →
#61 · Linked List
Coming SoonMedium

Rotate List

Rotate a linked list to the right by k places.

linked-listtwo-pointer
Visualization in progressPreview →
#100 · Tree
Coming SoonEasy

Same Tree

Decide whether two binary trees are structurally identical with matching values.

treedfs
Visualization in progressPreview →
#74 · Searching
Coming SoonMedium

Search a 2D Matrix

Treat a row-sorted matrix as a flat sorted array and binary search it.

binary-searchmatrix
Visualization in progressPreview →
Searching
Easy

Search Insert Position

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-searchsorted-array
Time O(log N) · Space O(1)Visualize →
#33 · Searching
Coming SoonMedium

Search in Rotated Sorted Array

Binary search a sorted array that has been rotated at an unknown pivot.

binary-search
Visualization in progressPreview →
#73 · Arrays
Coming SoonMedium

Set Matrix Zeroes

Whenever a cell is 0, zero out its entire row and column — ideally O(1) extra space.

matrix
Visualization in progressPreview →
#71 · Stack
Coming SoonMedium

Simplify Path

Canonicalize a Unix-style path using a stack of directory names.

stackstring
Visualization in progressPreview →
#136 · Math
Coming SoonEasy

Single Number

Every element appears twice except one — find it in O(1) extra space.

bit-manipulationxor
Visualization in progressPreview →
#137 · Math
Coming SoonMedium

Single Number II

Every element appears three times except one — find it.

bit-manipulation
Visualization in progressPreview →
#909 · Graph
Coming SoonMedium

Snakes and Ladders

Find the minimum number of dice rolls to reach the last square via BFS.

bfsmatrix
Visualization in progressPreview →
#148 · Linked List
Coming SoonMedium

Sort List

Sort a linked list in O(n log n) time using merge sort.

linked-listsortingdivide-and-conquer
Visualization in progressPreview →
#108 · Tree
Coming SoonEasy

Convert Sorted Array to Binary Search Tree

Build a height-balanced BST from a sorted array using the middle as the root.

treebstdivide-and-conquer
Visualization in progressPreview →
#54 · Arrays
Coming SoonMedium

Spiral Matrix

Traverse a 2D matrix in spiral order and return the visited values.

matrixsimulation
Visualization in progressPreview →
#69 · Math
Coming SoonEasy

Sqrt(x)

Integer square root of a non-negative integer.

mathbinary-search
Visualization in progressPreview →
#30 · String
Coming SoonHard

Substring with Concatenation of All Words

Find every starting index whose substring is a concatenation of all given words.

stringsliding-windowhashmap
Visualization in progressPreview →
#129 · Tree
Coming SoonMedium

Sum Root to Leaf Numbers

Sum every integer represented by a root-to-leaf digit path.

treedfs
Visualization in progressPreview →
#228 · Arrays
Coming SoonEasy

Summary Ranges

Collapse a sorted unique integer array into a list of inclusive range strings.

intervalsarray
Visualization in progressPreview →
#130 · Graph
Coming SoonMedium

Surrounded Regions

Capture every region of 'O' cells that is fully enclosed by 'X'.

matrixdfsbfs
Visualization in progressPreview →
#101 · Tree
Coming SoonEasy

Symmetric Tree

Decide whether a binary tree is a mirror image of itself around its center.

treedfs
Visualization in progressPreview →
#68 · String
Coming SoonHard

Text Justification

Fully justify lines of text to a fixed character width.

stringgreedy
Visualization in progressPreview →
#42 · Arrays
Coming SoonHard

Trapping Rain Water

Compute how much rainwater can be trapped between bars of an elevation map.

arraytwo-pointerstack
Visualization in progressPreview →
#120 · Dynamic Programming
Coming SoonMedium

Triangle

Minimum top-to-bottom path sum in a triangle of integers.

dp
Visualization in progressPreview →
#1 · Hash Map
Easy

Two Sum

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.

hashmaparray
Time O(N) · Space O(N)Visualize →
Arrays
Medium

Two Sum II - Input Array Is Sorted

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.

two-pointersorted-array
Time O(N) · Space O(1)Visualize →
#63 · Dynamic Programming
Coming SoonMedium

Unique Paths II

Count grid paths avoiding obstacles, moving right/down.

dpmatrix
Visualization in progressPreview →
#242 · Hash Map
Coming SoonEasy

Valid Anagram

Decide whether two strings are anagrams of each other.

hashmapstring
Visualization in progressPreview →
#125 · String
Easy

Valid Palindrome

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.

stringtwo-pointer
Time O(N) · Space O(1)Visualize →
Stack
Easy

Valid Parentheses (Stack Checker)

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.

stackstring
Time O(N) · Space O(N)Visualize →
#36 · Arrays
Coming SoonMedium

Valid Sudoku

Decide if a partially filled Sudoku board violates any row, column, or 3×3 box rule.

matrixhashmap
Visualization in progressPreview →
#98 · Tree
Medium

Validate Binary Search Tree

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.

treebstdfs
Time O(N) · Space O(H)Visualize →
#139 · Dynamic Programming
Coming SoonMedium

Word Break

Can the string be segmented into words from a dictionary?

dpstring
Visualization in progressPreview →
#127 · Graph
Coming SoonHard

Word Ladder

Find the shortest transformation chain between two words from a dictionary.

bfsstring
Visualization in progressPreview →
#290 · Hash Map
Coming SoonEasy

Word Pattern

Decide whether a string of words follows a given letter pattern.

hashmapstring
Visualization in progressPreview →
#79 · Backtracking
Coming SoonMedium

Word Search

Decide whether a word can be traced on a 2D character grid.

backtrackingmatrix
Visualization in progressPreview →
#212 · Tree
Coming SoonHard

Word Search II

Find every dictionary word that can be spelled by walking the grid (Trie + DFS).

triematrixbacktracking
Visualization in progressPreview →
#6 · String
Coming SoonMedium

Zigzag Conversion

Write a string in zigzag rows and read it back row by row.

string
Visualization in progressPreview →