LeetCode solutions in Java
Debug code with Intellij IDEA.
Linear List
Array
Remove Duplicates from Sorted ArrayRemove Duplicates from Sorted Array IILongest Consecutive SequenceTwo Sum3Sum3Sum Closest4SumRemove ElementMove ZeroesNext PermutationPermutation SequenceValid SudokuTrapping Rain WaterRotate ImagePlus OneClimbing StairsSet Matrix ZeroesGas StationCandyMajority ElementRotate ArrayContains DuplicateContains Duplicate IIContains Duplicate IIIProduct of Array Except SelfGame of LifeGame of Life IIIncreasing Triplet Subsequence
Linked List
Reverse Linked ListOdd Even Linked ListAdd Two NumbersReverse Linked List IIPartition ListRemove Duplicates from Sorted ListRemove Duplicates from Sorted List IIRotate ListRemove Nth Node From End of ListSwap Nodes in PairsReverse Nodes in k-GroupCopy List with Random PointerLinked List CycleLinked List Cycle IIReorder ListLRU CachePalindrome Linked List
String
Valid PalindromeImplement strStr()String to Integer (atoi)Add BinaryLongest Palindromic SubstringRegular Expression MatchingWildcard MatchingLongest Common PrefixValid NumberInteger to RomanRoman to IntegerCount and SayAnagramsValid AnagramSimplify PathLength of Last WordIsomorphic StringsWord Pattern
Stack && Queue
Stack
Min StackValid ParenthesesLongest Valid ParenthesesLargest Rectangle in HistogramEvaluate Reverse Polish NotationImplement Stack using Queues
Queue
Implement Queue using Stacks
Binary Tree
Traverse
Binary Tree Preorder TraversalBinary Tree Inorder TraversalBinary Tree Postorder TraversalBinary Tree Level Order TraversalBinary Tree Level Order Traversal IIBinary Tree Right Side ViewInvert Binary TreeBinary Search Tree IteratorBinary Tree Zigzag Level Order TraversalRecover Binary Search TreeSame TreeSymmetric TreeBalanced Binary TreeFlatten Binary Tree to Linked ListPopulating Next Right Pointers in Each Node II
Construct
Construct Binary Tree from Preorder and Inorder TraversalConstruct Binary Tree from Inorder and Postorder Traversal
Binary Search Tree
Unique Binary Search TreesUnique Binary Search Trees IIValidate Binary Search TreeConvert Sorted Array to Binary Search TreeConvert Sorted List to Binary Search TreeLCA of BSTKth Smallest Element in a BST
Recursion
Minimum Depth of Binary TreeMaximum Depth of Binary TreePath SumPath Sum II- Binary Tree Maximum Path Sum
- Populating Next Right Pointers in Each Node
- Sum Root to Leaf Numbers
LCA of Binary Tree
Segment Tree
Range Sum Query - Mutable
Sort
Insertion Sort
Insertion Sort List
Merge Sort
Merge Two Sorted Arrays- Merge Two Sorted Lists
- Merge k Sorted Lists
- Sort List
Quick Sort
- Sort Colors
- Kth Largest Element in an Array
Bucket Sort
- First Missing Positive
Counting Sort
- H-Index
Radix Sort
- Maximum Gap
Else
- Largest Number
Search
- Search for a Range
- Search Insert Position
- Search in Rotated Sorted Array
- Search in Rotated Sorted Array II
- Search a 2D Matrix
- Search a 2D Matrix II
- Find Minimum in Rotated Sorted Array
- Find Minimum in Rotated Sorted Array II
- Median of Two Sorted Arrays
- H-Index II
Exhaustive Attack
- Subsets
- Subsets II
- Permutations
- Permutations II
- Combinations
- Letter Combinations of a Phone Number
Breadth First Search
- Word Ladder
- Word Ladder II
- Surrounded Regions
Depth First Search
- Additive Number
- Palindrome Partitioning
Unique Paths- Unique Paths II
- N-Queens
- N-Queens II
- Restore IP Addresses
- Combination Sum
- Combination Sum II
- Combination Sum III
- Generate Parentheses
- Sudoku Solver
- Word Search
Divide and Conquer
- Pow(x,n)
- Sqrt(x)
Greedy
- Jump Game
- Jump Game II
Best Time to Buy and Sell StockBest Time to Buy and Sell Stock II- Longest Substring Without Repeating Characters
- Container With Most Water
- Patching Array
Couples Holding Hands
Dynamic Programming
TriangleMaximum SubarrayMaximum Product SubarrayLongest Increasing SubsequencePalindrome Partitioning IIMaximal RectangleBest Time to Buy and Sell Stock III- Best Time to Buy and Sell Stock IV
- Best Time to Buy and Sell Stock with Cooldown
- Interleaving String
- Scramble String
Minimum Path SumCoin ChangeShopping Offers- Edit Distance
- Decode Ways
- Distinct Subsequences
- Word Break
- Word Break II
- Dungeon Game
- House Robber
- House Robber II
- House Robber III
Range Sum Query - ImmutableRange Sum Query 2D - Immutable
Graph
- Clone Graph
Bit Manipulation
- Reverse Bits
- Repeated DNA Sequences
- Number of 1 Bits
- Gray Code
- Single Number
- Single Number II
- Single Number III
- Power of Two
- Missing Number
- Maximum Product of Word Lengths
- Bitwise AND of Numbers Range
- Power of Three
- Rectangle Area
Math
- Happy Number
- Ugly Number
- Ugly Number II
- Super Ugly Number
- Fraction to Recurring Decimal
- Factorial Trailing Zeroes
- Nim Game
Simulation
- Reverse Integer
- Palindrome Number
- Insert Interval
- Merge Intervals
- Minimum Window Substring
- Multiply Strings
- Substring with Concatenation of All Words
- Pascal's Triangle
- Pascal's Triangle II
- Spiral Matrix
- Spiral Matrix II
- ZigZag Conversion
- Divide Two Integers
- Text Justification
- Max Points on a Line