An algorithm problem contains 3 parts: input, output and solution/algorithm. The input can be an array, string, matrix, tree, linked list, graph, etc. The algorithm solution can be dynamic programming, binary search, BFS, DFS, or topological sort. The solution can also be a data structure, such as a stack, queue/dequeue, hash set, tree set, hash map, tree (heap, binary search tree, trie, segment tree, binary index tree), disjoint set, etc. In this file, problems are tagged by input data structures or algorithms.
- Remove Duplicates from Sorted Array I
- Remove Duplicates from Sorted Array II
- Candy
- Trapping Rain Water
- Product of Array Except Self
- Minimum Size Subarray Sum
- Summary Ranges
- Missing Ranges
- Merge Intervals
- Insert Interval
- Partition Labels
- Find and Replace in String
- My Calendar II
- One Edit Distance
- Merge Sorted Array
- Is Subsequence
- Backspace String Compare
- Repeated String Match
- Container with Most Water
- Reverse Vowels of a String
- Valid Palindrome
- Shortest Word Distance I
- Shortest Word Distance II
- Shortest Word Distance III
- Intersection of Two Arrays I
- Intersection of Two Arrays II
- Two Sum II
- Two Sum III
- Three Sum
- Four Sum
- Three Sum Closest
- Wiggle Sort
- Wiggle Subsequence
- Longest Common Prefix
- Next Permutation
- Sentence Screen Fitting
- Remove Element
- Move Zeroes
- Two Sum I
- Search Insert Position
- Median of Two Sorted Arrays
- Find Minimum in Rotated Sorted Array I
- Find Minimum in Rotated Sorted Array II
- Find First and Last Position of Element in Sorted Array
- Guess Number Higher or Lower
- First Bad Version
- Search in Rotated Array I
- Search in Rotated Array II
- Longest Increasing Subsequence
- Count of Smaller Numbers After Self
- Russian Doll Envelopes
- H-Index I
- H-Index II
- Valid Anagram
- Group Shifted Strings
- Palindrome Pairs
- Line Reflection
- Isomorphic Strings
- Two Sum
- Maximum Size Subarray Sum Equals k
- Subarray Sum Equals k
- Longest Substring Without Repeating Characters
- Longest Substring that contains k Unique Characters
- Substring with Concatenation of All Words
- Minimum Window Substring
- Longest Substring with At Least k Repeating Characters
- Permutation in String
- Longest Consecutive Sequence
- Majority Element I
- Majority Element II
- Increasing Triplet Subsequence
- Find the Second Largest Element in an Array
- Word Ladder I
- Word Ladder II
- Top k Frequent Elements
- Meeting Rooms I
- Meeting Rooms II
- Range Addition
- Merge k Sorted Arrays
- Merge k Sorted Lists
- Rearrange String k Distance Apart
- Minimum Cost to Hire k Workers
- Contains Duplicate I
- Contains Duplicate II
- Contains Duplicate III
- Max Sum of Rectangle No Larger than k
- Max Sum of Subarray Close to k
- k Empty Slots
- Sliding Window Maximum
- Moving Average from Data Stream
- Find Median from Data Stream
- Data Stream as Disjoint Intervals
- Linked List Random Node
- Shuffle an Array
- Mergesort
- Quicksort
- kth Largest Element in an Array
- Sort Colors (Counting Sort)
- Maximum Gap (Bucket Sort)
- Group Anagrams (Bucket Sort)
- Ugly Number I
- Ugly Number II
- Super Ugly Number
- Find k Pairs with Smallest Sums from Two Arrays
- Rotate Array
- Reverse Words in a String
- Missing Number
- Find the Duplicate Number
- First Missing Positive
- Queue Reconstruction by Height
- Binary Watch
- Next Closest Time
- Search a 2D Matrix I
- Search a 2D Matrix II
- kth Smallest Element in a Sorted Matrix
- Design Snake Game
- Number of Islands II
- Number of Connected Components in an Undirected Graph
- Most Stones Removed with Same Row or Column
- Longest Increasing Path in Matrix
- Word Search I
- Word Search II
- Number of Islands (DFS/BFS)
- Find a Path in a Matrix
- Sodoku Solver
- Valid Sodoku
- Walls and Gates (DFS/BFS)
- Surrounded Regions
- Set Matrix Zeroes
- Spiral Matrix I
- Spiral Matrix II
- Rotate Image
- Range Sum Query 2D - Immutable
- Shortest Distance from All Buildings
- Best Meeting Point
- Game of Life
- Tic Tac Toe
- Sparse Matrix Multiplication
- Add Two Numbers
- Reorder List
- Linked List Cycle
- Copy List with Random Pointer
- Merge Two Sorted Lists
- Odd Even Linked List
- Remove Duplicates from Sorted List I
- Remove Duplicates from Sorted List II
- Partition List
- Intersection of Two Linked Lists
- Remove Linked List Elements
- Swap Nodes in Pairs
- Reverse Linked List I
- Reverse Linked List II
- Reverse Double Linked List
- Print Linked List in Reversed Order
- Remove Nth Node From End of List (Fast-Slow Pointers)
- Palindrome Linked List
- Delete Node in a Linked List
- Reverse Nodes in k-Group
- Sort List
- Plus One Linked List
- Binary Tree Traversal
- Preorder
- Inorder
- Postorder
- Level Order I
- Level Order II
- Vertical Order
- Invert Binary Tree
- kth Smallest Element in a BST
- Binary Tree Longest Consecutive Sequence
- Validate Binary Search Tree
- Flatten Binary Tree to Linked List
- Path Sum I (DFS or BFS)
- Path Sum II (DFS)
- Construct Binary Tree from Inorder and Postorder Traversal
- Construct Binary Tree from Preorder and Inorder Traversal
- Convert Sorted Array to Binary Search Tree
- Convert Sorted List to Binary Search Tree
- Minimum Depth of Binary Tree
- Binary Tree Maximum Path Sum *
- Balanced Binary Tree
- Symmetric Tree
- Binary Search Tree Iterator
- Binary Tree Right Side View
- Lowest Common Ancestor of a Binary Search Tree
- Lowest Common Ancestor of a Binary Tree
- Most Frequent Subtree Sum
- Verify Preorder Serialization of a Binary Tree
- Populating Next Right Pointers in Each Node I
- Populating Next Right Pointers in Each Node II
- Unique Binary Search Trees I (DP)
- Unique Binary Search Trees II (DFS)
- Sum Root to Leaf Numbers (DFS)
- Count Complete Tree Nodes
- Closest Binary Search Tree Value
- Binary Tree Paths
- Maximum Depth of Binary Tree
- Recover Binary Search Tree
- Same Tree
- Serialize and Deserialize Binary Tree
- Inorder Successor in BST I
- Inorder Successor in BST II
- Find Leaves of Binary Tree
- Largest BST Subtree
- Convert BST to Sorted Doubly Linked List
- Implement Trie (Prefix Tree)
- Add and Search Word - Data structure design (DFS)
- Range Sum Query - Mutable
- The Skyline Problem
- Implement Stack using Queues
- Implement Queue using Stacks
- Implement a Stack Using an Array
- Implement a Queue using an Array
- Evaluate Reverse Polish Notation (Stack)
- Valid Parentheses
- Longest Valid Parentheses
- Min Stack
- Max Chunks To Make Sorted
- Largest Rectangle in Histogram
- Maximal Rectangle
- Mini Parser
- Flatten Nested List Iterator
- Nested List Weight Sum
- Nested List Weight Sum II (HashMap)
- Longest Absolute File Path
- Decode String
- Evaluate Math Expression
- Partition to K Equal Sum Subsets
- Permutations I
- Permutations II
- Permutation Sequence
- Number of Squareful Arrays
- Generate Parentheses
- Combination Sum (DFS) I
- Combination Sum (DFS) II
- Combination Sum (DFS) III
- Combination Sum (DFS) IV
- Wildcard Matching
- Regular Expression Matching
- Expressive Words
- Get Target Using Number List And Arithmetic Operations
- Flip Game I
- Flip Game II
- Word Pattern I
- Word Pattern II
- Scramble String
- Remove Invalid Parentheses
- Shortest Palindrome
- Lexicographical Numbers
- Combinations (DFS)
- Letter Combinations of a Phone Number (DFS)
- Restore IP Addresses
- Factor Combinations (DFS)
- Subsets I
- Subsets II
- Coin Change
- Palindrome Partitioning I
- Palindrome Partitioning II
- House Robber I
- House Robber II
- House Robber III
- Jump Game I
- Jump Game II
- Best Time to Buy and Sell Stock I
- Best Time to Buy and Sell Stock II
- Best Time to Buy and Sell Stock III
- Best Time to Buy and Sell Stock IV
- Dungeon Game
- Decode Ways
- Perfect Squares
- Word Break I
- Word Break II
- Minimum Window Subsequence
- Maximal Square
- Minimum Path Sum
- Unique Paths I
- Unique Paths II
- Paint House I
- Paint House II
- Maximum Subarray
- Maximum Product Subarray
- Edit Distance
- Distinct Subsequences Total
- Longest Palindromic Substring
- Longest Common Subsequence
- Longest Common Substring
- LRU Cache
- Insert Delete GetRandom O(1)
- Insert Delete GetRandom O(1) - Duplicates allowed
- Insert Delete GetMostFrequent O(1)
- Design Phone Directory
- Design Twitter
- Single Number I
- Single Number II
- Maximum Binary Gap
- Number of 1 Bits
- Reverse Bits
- Repeated DNA Sequences
- Bitwise AND of Numbers Range
- Sum of Two Integers
- Counting Bits
- Maximum Product of Word Lengths
- Gray Code
- UTF-8 Validation
- Course Schedule I
- Course Schedule II
- Minimum Height Trees
- Graph Valid Tree
- Clone Graph
- Reconstruct Itinerary
- Pow(x,n)
- Power of Two
- Power of Three
- Power of Four
- Super Pow
- Reverse Integer
- Palindrome Number
- Nth Digit
- Fraction to Recurring Decimal
- Excel Sheet Column Number
- Excel Sheet Column Title
- Factorial Trailing Zeroes
- Happy Number
- Count Primes
- Plus One
- Divide Two Integers
- Multiply Strings
- Max Points on a Line
- Integer Break
- Add Digits
- Largest Divisible Subset
- Count Numbers with Unique Digits
- Rotated Digits
- Remove k Digits
- Largest Number
- Triangle
- String to Integer
- Implement strStr()
- ZigZag Conversion
- Add Binary
- Length of Last Word
- Bulls and Cows
- Simplify Path
- Compare Version Numbers
- Pascal's Triangle I
- Pascal's Triangle II
- Count and Say
- Basic Calculator I
- Basic Calculator II
- Rectangle Area
- Find Peak Element
- Integer to English Words
- Text Justification
- Gas Station
- Self Crossing
- Patching Array
- Nim Game
- Bulb Switcher
- Pain Fence
- Nested List Weight Sum