LeetCode LeetCode C++ Solutions (Notes: "♥" means you need buy a book from Leetcode) # Title Solution Difficulty 173 Binary Search Tree Iterator C++ Medium 172 Factorial Trailing Zeroes C++ Easy 171 Excel Sheet Column Number C++ Easy 170 Two Sum III - Data structure design ♥ C++ Easy 169 Majority Element C++ Easy 168 Excel Sheet Column Title C++ Easy 167 Two Sum II - Input array is sorted ♥ C++ Medium 166 Fraction to Recurring Decimal C++ Medium 165 Compare Version Numbers C++ Easy 164 Maximum Gap C++ Hard 163 Missing Ranges ♥ C++ Medium 162 Find Peak Element C++ Medium 161 One Edit Distance♥ C++ Medium 160 Intersection of Two Linked Lists C++ Easy 159 Longest Substring with At Most Two Distinct Characters ♥ C++ Hard 158 Read N Characters Given Read4 II - Call multiple times ♥ C++ Hard 157 Read N Characters Given Read4 ♥ C++ Easy 156 Binary Tree Upside Down ♥ C++ Medium 155 Min Stack C++ Easy 154 Find Minimum in Rotated Sorted Array II C++ Hard 153 Find Minimum in Rotated Sorted Array C++ Medium 152 Maximum Product Subarray C++ Medium 151 Reverse Words in a String C++ Medium 150 Evaluate Reverse Polish Notation C++ Medium 149 Max Points on a Line C++ Hard 148 Sort List C++ Medium 147 Insertion Sort List C++ Medium 146 LRU Cache C++ Hard 145 Binary Tree Postorder Traversal C++ Hard 144 Binary Tree Preorder Traversal C++ Medium 143 Reorder List C++ Medium 142 Linked List Cycle II C++ Medium 141 Linked List Cycle C++ Medium 140 Word Break II C++ Hard 139 Word Break C++ Medium 138 Copy List with Random Pointer C++ Hard 137 Single Number II C++ Medium 136 Single Number C++ Medium 135 Candy C++ Hard 134 Gas Station C++ Medium 133 Clone Graph C++ Medium 132 Palindrome Partitioning II C++ Hard 131 Palindrome Partitioning C++ Medium 130 Surrounded Regions C++ Medium 129 Sum Root to Leaf Numbers C++ Medium 128 Longest Consecutive Sequence C++ Hard 127 Word Ladder II C++ Hard 126 Word Ladder C++ Medium 125 Valid Palindrome C++ Easy 124 Binary Tree Maximum Path Sum C++ Hard 123 Best Time to Buy and Sell Stock III C++ Hard 122 Best Time to Buy and Sell Stock II C++ Medium 121 Best Time to Buy and Sell Stock C++ Medium 120 Triangle C++ Medium 119 Pascal's Triangle II C++ Easy 118 Pascal's Triangle C++ Easy 117 Populating Next Right Pointers in Each Node II C++ Hard 116 Populating Next Right Pointers in Each Node C++ Medium 115 Distinct Subsequences C++ Hard 114 Flatten Binary Tree to Linked List C++ Medium 113 Path Sum II C++ Medium 112 Path Sum C++ Easy 111 Minimum Depth of Binary Tree C++ Easy 110 Balanced Binary Tree C++ Easy 109 Convert Sorted List to Binary Search Tree C++ Medium 108 Convert Sorted Array to Binary Search Tree C++ Medium 107 Binary Tree Level Order Traversal II C++ Easy 106 Construct Binary Tree from Inorder and Postorder Traversal C++ Medium 105 Construct Binary Tree from Preorder and Inorder Traversal C++ Medium 104 Maximum Depth of Binary Tree C++ Easy 103 Binary Tree Zigzag Level Order Traversal C++ Medium 102 Binary Tree Level Order Traversal C++ Easy 101 Symmetric Tree C++ Easy 100 Same Tree C++ Easy 99 Recover Binary Search Tree C++ Hard 98 Validate Binary Search Tree C++ Medium 97 Interleaving String C++ Hard 96 Unique Binary Search Trees II C++ Medium 95 Unique Binary Search Trees C++ Medium 94 Binary Tree Inorder Traversal C++ Medium 93 Restore IP Addresses C++ Medium 92 Reverse Linked List II C++ Medium 91 Subsets II C++ Medium 90 Decode Ways C++ Medium 89 Gray Code C++ Medium 88 Merge Sorted Array C++ Easy 87 Scramble String C++ Hard 86 Partition List C++ Medium 85 Maximal Rectangle C++ Hard 84 Largest Rectangle in Histogram C++ Hard 83 Remove Duplicates from Sorted List II C++ Medium 82 Remove Duplicates from Sorted List C++ Easy 81 Search in Rotated Sorted Array II C++ Medium 80 Remove Duplicates from Sorted Array II C++ Medium 79 Word Search C++ Medium 78 Subsets C++ Medium 77 Combinations C++ Medium 76 Minimum Window Substring C++ Hard 75 Sort Colors C++ Medium 74 Search a 2D Matrix C++ Medium 73 Set Matrix Zeroes C++ Medium 72 Edit Distance C++ Hard 71 Simplify Path C++ Medium 70 Climbing Stairs C++ Easy 69 Sqrt(x) C++ Medium 68 Text Justification C++ Hard 67 Plus One C++ Easy 66 Valid Number C++ Easy 65 Add Binary C++ Easy 64 Merge Two Sorted Lists C++ Easy 63 Minimum Path Sum C++ Medium 62 Unique Paths II C++ Medium 61 Unique Paths C++ Medium 60 Rotate List C++ Medium 59 Permutation Sequence C++ Medium 58 Spiral Matrix II C++ Medium 57 Length of Last Word C++ Easy 56 Insert Interval C++ Hard 55 Merge Intervals C++ Hard 54 Jump Game C++ Medium 53 Spiral Matrix C++ Medium 52 Maximum Subarray C++ Medium 51 N-Queens II C++ Hard 50 N-Queens C++ Hard 49 "Pow(x, n)" C++ Medium 48 Anagrams C++ Medium 47 Rotate Image C++ Medium 46 Permutations II C++ Hard 45 Permutations C++ Medium 44 Jump Game II C++ Hard 43 Wildcard Matching C++ Hard 42 Multiply Strings C++ Medium 41 Trapping Rain Water C++ Hard 40 First Missing Positive C++ Hard 39 Combination Sum II C++ Medium 38 Combination Sum C++ Medium 37 Count and Say C++ Easy 36 Sudoku Solver C++ Hard 35 Valid Sudoku C++ Easy 34 Search Insert Position C++ Medium 33 Search for a Range C++ Medium 32 Search in Rotated Sorted Array C++ Hard 31 Longest Valid Parentheses C++ Hard 30 Next Permutation C++ Medium 29 Substring with Concatenation of All Words C++ Hard 28 Divide Two Integers C++ Medium 27 Implement strStr() C++ Easy 26 Remove Element C++ Easy 25 Remove Duplicates from Sorted Array C++ Easy 24 Reverse Nodes in k-Group C++ Hard 23 Swap Nodes in Pairs C++ Medium 22 Merge k Sorted Lists C++ Hard 21 Generate Parentheses C++ Medium 20 Valid Parentheses C++ Easy 19 Remove Nth Node From End of List C++ Easy 18 Letter Combinations of a Phone Number C++ Medium 17 4Sum C++ Medium 16 3Sum Closest C++ Medium 15 3Sum C++ Medium 14 Longest Common Prefix C++ Easy 13 Roman to Integer C++ Easy 12 Integer to Roman C++ Medium 11 Container With Most Water C++ Medium 10 Regular Expression Matching C++ Hard 9 Palindrome Number C++ Easy 8 String to Integer (atoi) C++ Easy 7 Reverse Integer C++ Easy 6 ZigZag Conversion C++ Easy 5 Longest Palindromic Substring C++ Medium 4 Add Two Numbers C++ Medium 3 Longest Substring Without Repeating Characters C++ Medium 2 Median of Two Sorted Arrays C++ Hard 1 Two Sum C++ Medium