LeetCode LeetCode solutions gives some thoughts on selected problems. Solved 206/215 problems. Database See database.md Algorithms # Title Solution 231 Power of Two power-of-two.cc 230 Kth Smallest Element in a BST kth-smallest-element-in-a-bst.cc 229 Majority Element II majority-element-ii.cc 228 Summary Ranges summary-ranges.cc 227 Basic Calculator II basic-calculator-ii.cc 226 Invert Binary Tree invert-binary-tree.cc 225 Implement Stack using Queues implement-stack-using-queues.cc 224 Basic Calculator basic-calculator.cc 223 Rectangle Area rectangle-area.cc 222 Count Complete Tree Nodes count-complete-tree-nodes.cc 221 Maximal Square maximal-square.cc 220 Contains Duplicate III contains-duplicate-iii.cc 219 Contains Duplicate II contains-duplicate-ii.cc 218 The Skyline Problem the-skyline-problem.cc 217 Contains Duplicate contains-duplicate.cc 216 Combination Sum III combination-sum-iii.cc 215 Kth Largest Element in an Array kth-largest-element-in-an-array.cc 214 Shortest Palindrome shortest-palindrome.cc 213 House Robber II house-robber-ii.cc 212 Word Search II word-search-ii.cc 211 Add and Search Word - Data structure design add-and-search-word-data-structure-design.cc 210 Course Schedule II course-schedule-ii.cc 209 Minimum Size Subarray Sum minimum-size-subarray-sum.cc 208 Implement Trie (Prefix Tree) implement-trie-prefix-tree.cc 207 Course Schedule course-schedule.cc 206 Reverse Linked List reverse-linked-list.cc 205 Isomorphic Strings isomorphic-strings.cc 204 Count Primes count-primes.cc 203 Remove Linked List Elements remove-linked-list-elements.cc 202 Happy Number happy-number.cc 201 Bitwise AND of Numbers Range bitwise-and-of-numbers-range.cc 200 Number of Islands number-of-islands.cc 199 Binary Tree Right Side View binary-tree-right-side-view.cc 198 House Robber house-robber.cc 191 Number of 1 Bits number-of-1-bits.cc 190 Reverse Bits reverse-bits.cc 189 Rotate Array rotate-array.cc 188 Best Time to Buy and Sell Stock IV best-time-to-buy-and-sell-stock-iv.cc 187 Repeated DNA Sequences repeated-dna-sequences.cc 186 Reverse Words in a String II reverse-words-in-a-string-ii.cc 179 Largest Number largest-number.cc 174 Dungeon Game dungeon-game.cc 173 Binary Search Tree Iterator binary-search-tree-iterator.cc 172 Factorial Trailing Zeroes factorial-trailing-zeroes.cc 171 Excel Sheet Column Number excel-sheet-column-number.cc 170 Two Sum III - Data structure design two-sum-iii-data-structure-design.cc 169 Majority Element majority-element.cc 168 Excel Sheet Column Title excel-sheet-column-title.cc 167 Two Sum II - Input array is sorted two-sum-ii-input-array-is-sorted.cc 166 Fraction to Recurring Decimal fraction-to-recurring-decimal.cc 165 Compare Version Numbers compare-version-numbers.cc 164 Maximum Gap maximum-gap.cc 163 Missing Ranges missing-ranges.cc 162 Find Peak Element find-peak-element.cc 161 One Edit Distance one-edit-distance.cc 160 Intersection of Two Linked Lists intersection-of-two-linked-lists.cc 159 Longest Substring with At Most Two Distinct Characters longest-substring-with-at-most-two-distinct-characters.cc 158 Read N Characters Given Read4 II - Call multiple times read-n-characters-given-read4-ii-call-multiple-times.cc 157 Read N Characters Given Read4 read-n-characters-given-read4.cc 156 Binary Tree Upside Down binary-tree-upside-down.cc 155 Min Stack min-stack.cc 154 Find Minimum in Rotated Sorted Array II find-minimum-in-rotated-sorted-array-ii.cc 153 Find Minimum in Rotated Sorted Array find-minimum-in-rotated-sorted-array.cc 152 Maximum Product Subarray maximum-product-subarray.cc 151 Reverse Words in a String reverse-words-in-a-string.cc 150 Evaluate Reverse Polish Notation evaluate-reverse-polish-notation.cc 149 Max Points on a Line max-points-on-a-line.cc 148 Sort List sort-list.cc 147 Insertion Sort List insertion-sort-list.cc 146 LRU Cache lru-cache.cc 145 Binary Tree Postorder Traversal binary-tree-postorder-traversal.cc 144 Binary Tree Preorder Traversal binary-tree-preorder-traversal.cc 143 Reorder List reorder-list.cc 142 Linked List Cycle II linked-list-cycle-ii.cc 141 Linked List Cycle linked-list-cycle.cc 140 Word Break II word-break-ii.cc 139 Word Break word-break.cc 138 Copy List with Random Pointer copy-list-with-random-pointer.cc 137 Single Number II single-number-ii.cc 136 Single Number single-number.cc 135 Candy candy.cc 134 Gas Station gas-station.cc 133 Clone Graph clone-graph.cc 132 Palindrome Partitioning II palindrome-partitioning-ii.cc 131 Palindrome Partitioning palindrome-partitioning.cc 130 Surrounded Regions surrounded-regions.cc 129 Sum Root to Leaf Numbers sum-root-to-leaf-numbers.cc 128 Longest Consecutive Sequence longest-consecutive-sequence.cc 127 Word Ladder word-ladder.cc 126 Word Ladder II word-ladder-ii.cc 125 Valid Palindrome valid-palindrome.cc 124 Binary Tree Maximum Path Sum binary-tree-maximum-path-sum.cc 123 Best Time to Buy and Sell Stock III best-time-to-buy-and-sell-stock-iii.cc 122 Best Time to Buy and Sell Stock II best-time-to-buy-and-sell-stock-ii.cc 121 Best Time to Buy and Sell Stock best-time-to-buy-and-sell-stock.cc 120 Triangle triangle.cc 119 Pascal's Triangle II pascals-triangle-ii.cc 118 Pascal's Triangle pascals-triangle.cc 117 Populating Next Right Pointers in Each Node II populating-next-right-pointers-in-each-node-ii.cc 116 Populating Next Right Pointers in Each Node populating-next-right-pointers-in-each-node.cc 115 Distinct Subsequences distinct-subsequences.cc 114 Flatten Binary Tree to Linked List flatten-binary-tree-to-linked-list.cc 113 Path Sum II path-sum-ii.cc 112 Path Sum path-sum.cc 111 Minimum Depth of Binary Tree minimum-depth-of-binary-tree.cc 110 Balanced Binary Tree balanced-binary-tree.cc 109 Convert Sorted List to Binary Search Tree convert-sorted-list-to-binary-search-tree.cc 108 Convert Sorted Array to Binary Search Tree convert-sorted-array-to-binary-search-tree.cc 107 Binary Tree Level Order Traversal II binary-tree-level-order-traversal-ii.cc 106 Construct Binary Tree from Inorder and Postorder Traversal construct-binary-tree-from-inorder-and-postorder-traversal.cc 105 Construct Binary Tree from Preorder and Inorder Traversal construct-binary-tree-from-preorder-and-inorder-traversal.cc 104 Maximum Depth of Binary Tree maximum-depth-of-binary-tree.cc 103 Binary Tree Zigzag Level Order Traversal binary-tree-zigzag-level-order-traversal.cc 102 Binary Tree Level Order Traversal binary-tree-level-order-traversal.cc 101 Symmetric Tree symmetric-tree.cc 100 Same Tree same-tree.cc 99 Recover Binary Search Tree recover-binary-search-tree.cc 98 Validate Binary Search Tree validate-binary-search-tree.cc 97 Interleaving String interleaving-string.cc 96 Unique Binary Search Trees unique-binary-search-trees.cc 95 Unique Binary Search Trees II unique-binary-search-trees-ii.cc 94 Binary Tree Inorder Traversal binary-tree-inorder-traversal.cc 93 Restore IP Addresses restore-ip-addresses.cc 92 Reverse Linked List II reverse-linked-list-ii.cc 91 Decode Ways decode-ways.cc 90 Subsets II subsets-ii.cc 89 Gray Code gray-code.cc 88 Merge Sorted Array merge-sorted-array.cc 87 Scramble String scramble-string.cc 86 Partition List partition-list.cc 85 Maximal Rectangle maximal-rectangle.cc 84 Largest Rectangle in Histogram largest-rectangle-in-histogram.cc 83 Remove Duplicates from Sorted List remove-duplicates-from-sorted-list.cc 82 Remove Duplicates from Sorted List II remove-duplicates-from-sorted-list-ii.cc 81 Search in Rotated Sorted Array II search-in-rotated-sorted-array-ii.cc 80 Remove Duplicates from Sorted Array II remove-duplicates-from-sorted-array-ii.cc 79 Word Search word-search.cc 78 Subsets subsets.cc 77 Combinations combinations.cc 76 Minimum Window Substring minimum-window-substring.cc 75 Sort Colors sort-colors.cc 74 Search a 2D Matrix search-a-2d-matrix.cc 73 Set Matrix Zeroes set-matrix-zeroes.cc 72 Edit Distance edit-distance.cc 71 Simplify Path simplify-path.cc 70 Climbing Stairs climbing-stairs.cc 69 Sqrt(x) sqrtx.cc 68 Text Justification text-justification.cc 67 Add Binary add-binary.cc 66 Plus One plus-one.cc 65 Valid Number valid-number.cc 64 Minimum Path Sum minimum-path-sum.cc 63 Unique Paths II unique-paths-ii.cc 62 Unique Paths unique-paths.cc 61 Rotate List rotate-list.cc 60 Permutation Sequence permutation-sequence.cc 59 Spiral Matrix II spiral-matrix-ii.cc 58 Length of Last Word length-of-last-word.cc 57 Insert Interval insert-interval.cc 56 Merge Intervals merge-intervals.cc 55 Jump Game jump-game.cc 54 Spiral Matrix spiral-matrix.cc 53 Maximum Subarray maximum-subarray.cc 52 N-Queens II n-queens-ii.cc 51 N-Queens n-queens.cc 50 Pow(x, n) powx-n.cc 49 Anagrams anagrams.cc 48 Rotate Image rotate-image.cc 47 Permutations II permutations-ii.cc 46 Permutations permutations.cc 45 Jump Game II jump-game-ii.cc 44 Wildcard Matching wildcard-matching.cc 43 Multiply Strings multiply-strings.cc 42 Trapping Rain Water trapping-rain-water.cc 41 First Missing Positive first-missing-positive.cc 40 Combination Sum II combination-sum-ii.cc 39 Combination Sum combination-sum.cc 38 Count and Say count-and-say.cc 37 Sudoku Solver sudoku-solver.cc 36 Valid Sudoku valid-sudoku.cc 35 Search Insert Position search-insert-position.cc 34 Search for a Range search-for-a-range.cc 33 Search in Rotated Sorted Array search-in-rotated-sorted-array.cc 32 Longest Valid Parentheses longest-valid-parentheses.cc 31 Next Permutation next-permutation.cc 30 Substring with Concatenation of All Words substring-with-concatenation-of-all-words.cc 29 Divide Two Integers divide-two-integers.cc 28 Implement strStr() implement-strstr.cc 27 Remove Element remove-element.cc 26 Remove Duplicates from Sorted Array remove-duplicates-from-sorted-array.cc 25 Reverse Nodes in k-Group reverse-nodes-in-k-group.cc 24 Swap Nodes in Pairs swap-nodes-in-pairs.cc 23 Merge k Sorted Lists merge-k-sorted-lists.cc 22 Generate Parentheses generate-parentheses.cc 21 Merge Two Sorted Lists merge-two-sorted-lists.cc 20 Valid Parentheses valid-parentheses.cc 19 Remove Nth Node From End of List remove-nth-node-from-end-of-list.cc 18 4Sum 4sum.cc 17 Letter Combinations of a Phone Number letter-combinations-of-a-phone-number.cc 16 3Sum Closest 3sum-closest.cc 15 3Sum 3sum.cc 14 Longest Common Prefix longest-common-prefix.cc 13 Roman to Integer roman-to-integer.cc 12 Integer to Roman integer-to-roman.cc 11 Container With Most Water container-with-most-water.cc 10 Regular Expression Matching regular-expression-matching.cc 9 Palindrome Number palindrome-number.cc 8 String to Integer (atoi) string-to-integer-atoi.cc 7 Reverse Integer reverse-integer.cc 6 ZigZag Conversion zigzag-conversion.cc 5 Longest Palindromic Substring longest-palindromic-substring.cc 4 Median of Two Sorted Arrays median-of-two-sorted-arrays.cc 3 Longest Substring Without Repeating Characters longest-substring-without-repeating-characters.cc 2 Add Two Numbers add-two-numbers.cc 1 Two Sum two-sum.cc