Skip to content

IsaacAU/LeetCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

LeetCode Catagory

N-Sum

[Two Sum](codes/Two Sum.cpp)
3 Sum
[3 Sum Closest](codes/3Sum Closest.cpp)
4 Sum
[Two Sum III - Data structure design](codes/Two Sum III - Data structure design.cpp)

Singly linked list

[Add Two Numbers](codes/Add Two Numbers.cpp)
[Remove Nth Node From End of List](codes/Remove Nth Node From End of List.cpp)
[Merge Two Sorted Lists](codes/Merge Two Sorted Lists.cpp)
[Merge k Sorted Lists](codes/Merge k Sorted Lists.cpp)
[Swap Nodes in Pairs](codes/Swap Nodes in Pairs.cpp)
[Reverse Nodes in k-Group](codes/Reverse Nodes in k-Group.cpp)
[Rotate List](codes/Rotate List.cpp)
[Remove Duplicates from Sorted List](codes/Remove Duplicates from Sorted List.cpp)
[Remove Duplicates from Sorted List II](codes/Remove Duplicates from Sorted List II.cpp)
[Partition List](codes/Partition List.cpp)
[Reverse Linked List II](codes/Reverse Linked List II.cpp)
[Copy List with Random Pointer](codes/Copy List with Random Pointer.cpp)
[Linked List Cycle](codes/Linked List Cycle.cpp)
[Linked List Cycle II](codes/Linked List Cycle II.cpp)
[Reorder List](codes/Reorder List.cpp)
[Insertion Sort List](codes/Insertion Sort List.cpp)
[Sort List](codes/Sort List.cpp)
[Intersection of Two Linked Lists](codes/Intersection of Two Linked Lists.cpp)

Binary Tree

[Binary Tree Preorder Traversal](codes/Binary Tree Preorder Traversal.cpp) (view this)
[Binary Tree Inorder Traversal](codes/Binary Tree Inorder Traversal.cpp) (view this)
[Binary Tree Postorder Traversal](codes/Binary Tree Postorder Traversal.cpp) (view this)
[Unique Binary Search Trees](codes/Unique Binary Search Trees.cpp)
[Unique Binary Search Trees II](codes/Unique Binary Search Trees II.cpp)
[Validate Binary Search Tree](codes/Validate Binary Search Tree.cpp)
[Recover Binary Search Tree](codes/Recover Binary Search Tree.cpp)
[Same Tree](codes/Same Tree.cpp)
[Symmetric Tree](codes/Symmetric Tree.cpp)
[Binary Tree Level Order Traversal](codes/Binary Tree Level Order Traversal.cpp)
[Binary Tree Level Order Traversal II](codes/Binary Tree Level Order Traversal II.cpp)
[Binary Tree Zigzag Level Order Traversal](codes/Binary Tree Zigzag Level Order Traversal.cpp)
[Maximum Depth of Binary Tree](codes/Maximum Depth of Binary Tree.cpp)
[Minimum Depth of Binary Tree](codes/Minimum Depth of Binary Tree.cpp)
[Balanced Binary Tree](codes/Balanced Binary Tree.cpp)
[Path Sum](codes/Path Sum.cpp)
[Path Sum II](codes/Path Sum II.cpp)
[Binary Tree Maximum Path Sum](codes/Binary Tree Maximum Path Sum.cpp)
[Sum Root to Leaf Numbers](codes/Sum Root to Leaf Numbers.cpp)
[Construct Binary Tree from Preorder and Inorder Traversal](codes/Construct Binary Tree from Preorder and Inorder Traversal.cpp)
[Construct Binary Tree from Inorder and Postorder Traversal](codes/Construct Binary Tree from Inorder and Postorder Traversal.cpp)
[Convert Sorted Array to Binary Search Tree](codes/Convert Sorted Array to Binary Search Tree.cpp)
[Convert Sorted List to Binary Search Tree](codes/Convert Sorted List to Binary Search Tree.cpp)
[Flatten Binary Tree to Linked List](codes/Flatten Binary Tree to Linked List.cpp)
[Populating Next Right Pointers in Each Node](codes/Populating Next Right Pointers in Each Node.cpp)
[Populating Next Right Pointers in Each Node II](codes/Populating Next Right Pointers in Each Node II.cpp)
[Binary Search Tree Iterator](codes/Binary Search Tree Iterator.cpp)

String

[ZigZag Conversion](codes/ZigZag Conversion.cpp)
[String to Integer (atoi)](codes/String to Integer (atoi).cpp)
[Implement strStr()](codes/Implement strStr().cpp)
[Regular Expression Matching](codes/Regular Expression Matching.cpp)
[Wildcard Matching](codes/Wildcard Matching.cpp)
[Longest Common Prefix](codes/Longest Common Prefix.cpp)
[Longest Substring Without Repeating Characters](codes/Longest Substring Without Repeating Characters.cpp)
[Longest Substring with At Most Two Distinct Characters](codes/Longest Substring with At Most Two Distinct Characters.cpp)
[Longest Palindromic Substring](codes/Longest Palindromic Substring.cpp)
[Substring with Concatenation of All Words](codes/Substring with Concatenation of All Words.cpp)
[Count and Say](codes/Count and Say.cpp)
Anagrams
[Length of Last Word](codes/Length of Last Word.cpp)
[Valid Number](codes/Valid Number.cpp) (Easy to understand idea!)
[Simplify Path](codes/Simplify Path.cpp)
[Edit Distance](codes/Edit Distance.cpp)
[One Edit Distance](codes/One Edit Distance.cpp)
[Minimum Window Substring](codes/Minimum Window Substring.cpp)
[Scramble String](codes/Scramble String.cpp)
[Decode Ways](codes/Decode Ways.cpp)
[Restore IP Addresses](codes/Restore IP Addresses.cpp)
[Interleaving String](codes/Interleaving String.cpp)
[Distinct Subsequences](codes/Distinct Subsequences.cpp)
[Valid Palindrome](codes/Valid Palindrome.cpp)
[Word Ladder](codes/Word Ladder.cpp)
[Word Ladder II](codes/Word Ladder II.cpp)
[Palindrome Partitioning](codes/Palindrome Partitioning.cpp)
[Palindrome Partitioning II](codes/Palindrome Partitioning II.cpp)
[Word Break](codes/Word Break.cpp)
[Word Break II](codes/Word Break II.cpp)
[Evaluate Reverse Polish Notation](codes/Evaluate Reverse Polish Notation.cpp)
[Reverse Words in a String](codes/Reverse Words in a String.cpp)
[Read N Characters Given Read4](codes/Read N Characters Given Read4.cpp)
[Read N Characters Given Read4 II - Call multiple times](codes/Read N Characters Given Read4 II - Call multiple times.cpp)
[Compare Version Numbers](codes/Compare Version Numbers.cpp)
[Excel Sheet Column Title](codes/Excel Sheet Column Title.cpp)
[Excel Sheet Column Number](codes/Excel Sheet Column Number.cpp)
[Largest Number](codes/Largest Number.cpp)
[Integer to Roman](codes/Integer to Roman.cpp)
[Roman to Integer](codes/Roman to Integer.cpp)
[Text Justification](codes/Text Justification.cpp)

Parentheses (Catalan number)

[Valid Parentheses](codes/Valid Parentheses.cpp)
[Generate Parentheses](codes/Generate Parentheses.cpp)
[Longest Valid Parentheses](codes/Longest Valid Parentheses.cpp)

Permutations

[Next Permutation](codes/Next Permutation.cpp)
Permutations
[Permutations II](codes/Permutations II.cpp)
[Permutation Sequence](codes/Permutation Sequence.cpp)

Combination

Combinations
[Combination Sum](codes/Combination Sum.cpp)
[Combination Sum II](codes/Combination Sum II.cpp)
[Letter Combinations of a Phone Number](codes/Letter Combinations of a Phone Number.cpp)
Subsets
[Subsets II](codes/Subsets II.cpp)
[Gray Code](codes/Gray Code.cpp)

Bit Manipulation

[Single Number](codes/Single Number.cpp)
[Single Number II](codes/Single Number II.cpp)

Binary Search

[Find Minimum in Rotated Sorted Array](codes/Find Minimum in Rotated Sorted Array.cpp)
[Find Minimum in Rotated Sorted Array II](codes/Find Minimum in Rotated Sorted Array II.cpp)
[Search in Rotated Sorted Array](codes/Search in Rotated Sorted Array.cpp)
[Search in Rotated Sorted Array II](codes/Search in Rotated Sorted Array II.cpp)
[Median of Two Sorted Arrays](codes/Median of Two Sorted Arrays.cpp)
[Search for a Range](codes/Search for a Range.cpp)
[Search Insert Position](codes/Search Insert Position.cpp)
[Search a 2D Matrix](codes/Search a 2D Matrix.cpp)

Numbers

[Reverse Integer](codes/Reverse Integer.cpp)
[Palindrome Number](codes/Palindrome Number.cpp)
[Divide Two Integers](codes/Divide Two Integers.cpp)
[Pow(x, n)](codes/Pow(x, n).cpp)
Sqrt(x)
[Fraction to Recurring Decimal](codes/Fraction to Recurring Decimal.cpp)
[Factorial Trailing Zeroes](codes/Factorial Trailing Zeroes.cpp)

Big Data

[Multiply Strings](codes/Multiply Strings.cpp)
[Plus One](codes/Plus One.cpp)
[Add Binary](codes/Add Binary.cpp)

Arrays

[Container With Most Water](codes/Container With Most Water.cpp)
[Trapping Rain Water](codes/Trapping Rain Water.cpp)
[Largest Rectangle in Histogram](codes/Largest Rectangle in Histogram.cpp)
[Remove Duplicates from Sorted Array](codes/Remove Duplicates from Sorted Array.cpp)
[Remove Duplicates from Sorted Array II](codes/Remove Duplicates from Sorted Array II.cpp)
[Remove Element](codes/Remove Element.cpp)
[First Missing Positive](codes/First Missing Positive.cpp)
[Jump Game](codes/Jump Game.cpp)
[Jump Game II](codes/Jump Game II.cpp)
[Maximum Subarray](codes/Maximum Subarray.cpp)
[Maximum Product Subarray](codes/Maximum Product Subarray.cpp)
[Climbing Stairs](codes/Climbing Stairs.cpp)
[Sort Colors](codes/Sort Colors.cpp)
[Merge Sorted Array](codes/Merge Sorted Array.cpp)
[Best Time to Buy and Sell Stock](codes/Best Time to Buy and Sell Stock.cpp)
[Best Time to Buy and Sell Stock II](codes/Best Time to Buy and Sell Stock II.cpp)
[Best Time to Buy and Sell Stock III](codes/Best Time to Buy and Sell Stock III.cpp)
[Longest Consecutive Sequence](codes/Longest Consecutive Sequence.cpp)
[Gas Station](codes/Gas Station.cpp)
Candy
[Find Peak Element](codes/Find Peak Element.cpp)
[Majority Element](codes/Majority Element.cpp) (Moore’s Voting Algorithm)
[Maximum Gap](codes/Maximum Gap.cpp) (Bucket Sort)

Intervals

[Merge Intervals](codes/Merge Intervals.cpp)
[Insert Interval](codes/Insert Interval.cpp)

About

Practice C++ on LeetCode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages