|
| 1 | +# go-leetcode |
| 2 | + |
| 3 | +A collection of 100+ popular [LeetCode](https://leetcode.com/) problems solved in |
| 4 | +[Go](https://golang.org/). |
| 5 | + |
| 6 | +Each directory includes a: |
| 7 | +- Description with link to LeetCode problem |
| 8 | +- Solution to the problem |
| 9 | +- A unit test |
| 10 | + |
| 11 | +Note that each of these problems **have passed** their respective test cases on LeetCode. The unit |
| 12 | +tests included with each solution in this repo are not comprehensive. They serve as a quick way to |
| 13 | +drop in a test case, hook up the debugger, and step through the algorithms to build understanding. |
| 14 | + |
| 15 | +## Problems |
| 16 | + |
| 17 | +There are a variety of popular LeetCode problems solved in this repository. However, most of the problems |
| 18 | +solved are from a highly recommended, curated list of problems called |
| 19 | +[Top 75 LeetCode Problems](https://www.teamblind.com/post/New-Year-Gift---Curated-List-of-Top-100-LeetCode-Questions-to-Save-Your-Time-OaM1orEU). |
| 20 | + |
| 21 | +The [Top 75 LeetCode Problems](https://www.teamblind.com/post/New-Year-Gift---Curated-List-of-Top-100-LeetCode-Questions-to-Save-Your-Time-OaM1orEU) |
| 22 | +list is comprehensive, covering a decent breadth and depth for each category. Working through that list will certainly |
| 23 | +help build the core concepts, techniques, and intuition needed to solve these types of problems. |
| 24 | + |
| 25 | +I've included a checklist that you can use to work through the list below: |
| 26 | + |
| 27 | +#### Array |
| 28 | + |
| 29 | +- [X] Two Sum - [https://leetcode.com/problems/two-sum/](https://leetcode.com/problems/two-sum/) |
| 30 | +- [X] Best Time to Buy and Sell Stock - [https://leetcode.com/problems/best-time-to-buy-and-sell-stock/](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/) |
| 31 | +- [X] Contains Duplicate - [https://leetcode.com/problems/contains-duplicate/](https://leetcode.com/problems/contains-duplicate/) |
| 32 | +- [X] Product of Array Except Self - [https://leetcode.com/problems/product-of-array-except-self/](https://leetcode.com/problems/product-of-array-except-self/) |
| 33 | +- [X] Maximum Subarray - [https://leetcode.com/problems/maximum-subarray/](https://leetcode.com/problems/maximum-subarray/) |
| 34 | +- [X] Maximum Product Subarray - [https://leetcode.com/problems/maximum-product-subarray/](https://leetcode.com/problems/maximum-product-subarray/) |
| 35 | +- [X] Find Minimum in Rotated Sorted Array - [https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/) |
| 36 | +- [X] Search in Rotated Sorted Array - [https://leetcode.com/problems/search-in-rotated-sorted-array/](https://leetcode.com/problems/search-in-rotated-sorted-array/) |
| 37 | +- [X] 3Sum - [https://leetcode.com/problems/3sum/](https://leetcode.com/problems/3sum/) |
| 38 | +- [X] Container With Most Water - [https://leetcode.com/problems/container-with-most-water/](https://leetcode.com/problems/container-with-most-water/) |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +#### Binary |
| 43 | + |
| 44 | +- [X] Sum of Two Integers - [https://leetcode.com/problems/sum-of-two-integers/](https://leetcode.com/problems/sum-of-two-integers/) |
| 45 | +- [X] Number of 1 Bits - [https://leetcode.com/problems/number-of-1-bits/](https://leetcode.com/problems/number-of-1-bits/) |
| 46 | +- [X] Counting Bits - [https://leetcode.com/problems/counting-bits/](https://leetcode.com/problems/counting-bits/) |
| 47 | +- [X] Missing Number - [https://leetcode.com/problems/missing-number/](https://leetcode.com/problems/missing-number/) |
| 48 | +- [X] Reverse Bits - [https://leetcode.com/problems/reverse-bits/](https://leetcode.com/problems/reverse-bits/) |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +#### Dynamic Programming |
| 53 | + |
| 54 | +- [X] Climbing Stairs - [https://leetcode.com/problems/climbing-stairs/](https://leetcode.com/problems/climbing-stairs/) |
| 55 | +- [X] Coin Change - [https://leetcode.com/problems/coin-change/](https://leetcode.com/problems/coin-change/) |
| 56 | +- [X] Longest Increasing Subsequence - [https://leetcode.com/problems/longest-increasing-subsequence/](https://leetcode.com/problems/longest-increasing-subsequence/) |
| 57 | +- [X] Longest Common Subsequence - [https://leetcode.com/problems/longest-common-subsequence/](https://leetcode.com/problems/longest-common-subsequence/) |
| 58 | +- [X] Word Break Problem - [https://leetcode.com/problems/word-break/](https://leetcode.com/problems/word-break/) |
| 59 | +- [X] Combination Sum - [https://leetcode.com/problems/combination-sum-iv/](https://leetcode.com/problems/combination-sum-iv/) |
| 60 | +- [X] House Robber - [https://leetcode.com/problems/house-robber/](https://leetcode.com/problems/house-robber/) |
| 61 | +- [X] House Robber II - [https://leetcode.com/problems/house-robber-ii/](https://leetcode.com/problems/house-robber-ii/) |
| 62 | +- [X] Decode Ways - [https://leetcode.com/problems/decode-ways/](https://leetcode.com/problems/decode-ways/) |
| 63 | +- [X] Unique Paths - [https://leetcode.com/problems/unique-paths/](https://leetcode.com/problems/unique-paths/) |
| 64 | +- [X] Jump Game - [https://leetcode.com/problems/jump-game/](https://leetcode.com/problems/jump-game/) |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +#### Graph |
| 69 | + |
| 70 | +- [X] Clone Graph - [https://leetcode.com/problems/clone-graph/](https://leetcode.com/problems/clone-graph/) |
| 71 | +- [X] Course Schedule - [https://leetcode.com/problems/course-schedule/](https://leetcode.com/problems/course-schedule/) |
| 72 | +- [X] Pacific Atlantic Water Flow - [https://leetcode.com/problems/pacific-atlantic-water-flow/](https://leetcode.com/problems/pacific-atlantic-water-flow/) |
| 73 | +- [X] Number of Islands - [https://leetcode.com/problems/number-of-islands/](https://leetcode.com/problems/number-of-islands/) |
| 74 | +- [X] Longest Consecutive Sequence - [https://leetcode.com/problems/longest-consecutive-sequence/](https://leetcode.com/problems/longest-consecutive-sequence/) |
| 75 | +- [X] Alien Dictionary (Leetcode Premium) - [https://leetcode.com/problems/alien-dictionary/](https://leetcode.com/problems/alien-dictionary/) |
| 76 | +- [X] Graph Valid Tree (Leetcode Premium) - [https://leetcode.com/problems/graph-valid-tree/](https://leetcode.com/problems/graph-valid-tree/) |
| 77 | +- [X] Number of Connected Components in an Undirected Graph (Leetcode Premium) - [https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/) |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +#### Interval |
| 82 | + |
| 83 | +- [X] Insert Interval - [https://leetcode.com/problems/insert-interval/](https://leetcode.com/problems/insert-interval/) |
| 84 | +- [X] Merge Intervals - [https://leetcode.com/problems/merge-intervals/](https://leetcode.com/problems/merge-intervals/) |
| 85 | +- [X] Non-overlapping Intervals - [https://leetcode.com/problems/non-overlapping-intervals/](https://leetcode.com/problems/non-overlapping-intervals/) |
| 86 | +- [X] Meeting Rooms (Leetcode Premium) - [https://leetcode.com/problems/meeting-rooms/](https://leetcode.com/problems/meeting-rooms/) |
| 87 | +- [X] Meeting Rooms II (Leetcode Premium) - [https://leetcode.com/problems/meeting-rooms-ii/](https://leetcode.com/problems/meeting-rooms-ii/) |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +#### Linked List |
| 92 | + |
| 93 | +- [X] Reverse a Linked List - [https://leetcode.com/problems/reverse-linked-list/](https://leetcode.com/problems/reverse-linked-list/) |
| 94 | +- [X] Detect Cycle in a Linked List - [https://leetcode.com/problems/linked-list-cycle/](https://leetcode.com/problems/linked-list-cycle/) |
| 95 | +- [X] Merge Two Sorted Lists - [https://leetcode.com/problems/merge-two-sorted-lists/](https://leetcode.com/problems/merge-two-sorted-lists/) |
| 96 | +- [X] Merge K Sorted Lists - [https://leetcode.com/problems/merge-k-sorted-lists/](https://leetcode.com/problems/merge-k-sorted-lists/) |
| 97 | +- [X] Remove Nth Node From End Of List - [https://leetcode.com/problems/remove-nth-node-from-end-of-list/](https://leetcode.com/problems/remove-nth-node-from-end-of-list/) |
| 98 | +- [X] Reorder List - [https://leetcode.com/problems/reorder-list/](https://leetcode.com/problems/reorder-list/) |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +#### Matrix |
| 103 | + |
| 104 | +- [X] Set Matrix Zeroes - [https://leetcode.com/problems/set-matrix-zeroes/](https://leetcode.com/problems/set-matrix-zeroes/) |
| 105 | +- [X] Spiral Matrix - [https://leetcode.com/problems/spiral-matrix/](https://leetcode.com/problems/spiral-matrix/) |
| 106 | +- [X] Rotate Image - [https://leetcode.com/problems/rotate-image/](https://leetcode.com/problems/rotate-image/) |
| 107 | +- [X] Word Search - [https://leetcode.com/problems/word-search/](https://leetcode.com/problems/word-search/) |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +#### String |
| 112 | + |
| 113 | +- [X] Longest Substring Without Repeating Characters - [https://leetcode.com/problems/longest-substring-without-repeating-characters/](https://leetcode.com/problems/longest-substring-without-repeating-characters/) |
| 114 | +- [X] Longest Repeating Character Replacement - [https://leetcode.com/problems/longest-repeating-character-replacement/](https://leetcode.com/problems/longest-repeating-character-replacement/) |
| 115 | +- [X] Minimum Window Substring - [https://leetcode.com/problems/minimum-window-substring/](https://leetcode.com/problems/minimum-window-substring/) |
| 116 | +- [X] Valid Anagram - [https://leetcode.com/problems/valid-anagram/](https://leetcode.com/problems/valid-anagram/) |
| 117 | +- [X] Group Anagrams - [https://leetcode.com/problems/group-anagrams/](https://leetcode.com/problems/group-anagrams/) |
| 118 | +- [X] Valid Parentheses - [https://leetcode.com/problems/valid-parentheses/](https://leetcode.com/problems/valid-parentheses/) |
| 119 | +- [X] Valid Palindrome - [https://leetcode.com/problems/valid-palindrome/](https://leetcode.com/problems/valid-palindrome/) |
| 120 | +- [X] Longest Palindromic Substring - [https://leetcode.com/problems/longest-palindromic-substring/](https://leetcode.com/problems/longest-palindromic-substring/) |
| 121 | +- [X] Palindromic Substrings - [https://leetcode.com/problems/palindromic-substrings/](https://leetcode.com/problems/palindromic-substrings/) |
| 122 | +- [X] Encode and Decode Strings (Leetcode Premium) - [https://leetcode.com/problems/encode-and-decode-strings/](https://leetcode.com/problems/encode-and-decode-strings/) |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +#### Tree |
| 127 | + |
| 128 | +- [X] Maximum Depth of Binary Tree - [https://leetcode.com/problems/maximum-depth-of-binary-tree/](https://leetcode.com/problems/maximum-depth-of-binary-tree/) |
| 129 | +- [X] Same Tree - [https://leetcode.com/problems/same-tree/](https://leetcode.com/problems/same-tree/) |
| 130 | +- [X] Invert/Flip Binary Tree - [https://leetcode.com/problems/invert-binary-tree/](https://leetcode.com/problems/invert-binary-tree/) |
| 131 | +- [X] Binary Tree Maximum Path Sum - [https://leetcode.com/problems/binary-tree-maximum-path-sum/](https://leetcode.com/problems/binary-tree-maximum-path-sum/) |
| 132 | +- [X] Binary Tree Level Order Traversal - [https://leetcode.com/problems/binary-tree-level-order-traversal/](https://leetcode.com/problems/binary-tree-level-order-traversal/) |
| 133 | +- [X] Serialize and Deserialize Binary Tree - [https://leetcode.com/problems/serialize-and-deserialize-binary-tree/](https://leetcode.com/problems/serialize-and-deserialize-binary-tree/) |
| 134 | +- [X] Subtree of Another Tree - [https://leetcode.com/problems/subtree-of-another-tree/](https://leetcode.com/problems/subtree-of-another-tree/) |
| 135 | +- [X] Construct Binary Tree from Preorder and Inorder Traversal - [https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) |
| 136 | +- [X] Validate Binary Search Tree - [https://leetcode.com/problems/validate-binary-search-tree/](https://leetcode.com/problems/validate-binary-search-tree/) |
| 137 | +- [X] Kth Smallest Element in a BST - [https://leetcode.com/problems/kth-smallest-element-in-a-bst/](https://leetcode.com/problems/kth-smallest-element-in-a-bst/) |
| 138 | +- [X] Lowest Common Ancestor of BST - [https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/) |
| 139 | +- [X] Implement Trie (Prefix Tree) - [https://leetcode.com/problems/implement-trie-prefix-tree/](https://leetcode.com/problems/implement-trie-prefix-tree/) |
| 140 | +- [X] Add and Search Word - [https://leetcode.com/problems/add-and-search-word-data-structure-design/](https://leetcode.com/problems/add-and-search-word-data-structure-design/) |
| 141 | +- [X] Word Search II - [https://leetcode.com/problems/word-search-ii/](https://leetcode.com/problems/word-search-ii/) |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +#### Heap |
| 146 | + |
| 147 | +- [X] Merge K Sorted Lists - [https://leetcode.com/problems/merge-k-sorted-lists/](https://leetcode.com/problems/merge-k-sorted-lists/) |
| 148 | +- [X] Top K Frequent Elements - [https://leetcode.com/problems/top-k-frequent-elements/](https://leetcode.com/problems/top-k-frequent-elements/) |
| 149 | +- [X] Find Median from Data Stream - [https://leetcode.com/problems/find-median-from-data-stream/](https://leetcode.com/problems/find-median-from-data-stream/) |
0 commit comments