Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/austingebauer/go-leetcode

A collection of 100+ popular LeetCode problems solved in Go.
https://github.com/austingebauer/go-leetcode

ctci leetcode

Last synced: 7 days ago
JSON representation

A collection of 100+ popular LeetCode problems solved in Go.

Awesome Lists containing this project

README

        

# go-leetcode

A collection of 100+ popular [LeetCode](https://leetcode.com/) problems that I've solved in
[Go](https://golang.org/).

Each directory includes a:
- Description with link to LeetCode problem
- Solution to the problem
- Unit test

Note that each of these problems **have passed** their respective test cases on LeetCode. The unit
tests included with each solution in this repo are not comprehensive. They serve as a quick way to
drop in a test case, hook up the debugger, and step through the algorithms to build understanding.

Also note that some of my personal comments are in the solutions. I'll be working to clean up
anything that is not insightful.

## Problems

There are a variety of popular LeetCode problems solved in this repository. However, most of the problems
solved are from a highly recommended, curated list of problems called
[Top 75 LeetCode Problems](https://www.teamblind.com/post/New-Year-Gift---Curated-List-of-Top-100-LeetCode-Questions-to-Save-Your-Time-OaM1orEU).

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)
list is comprehensive, covering a decent breadth and depth for each category. Working through that list will certainly
help build the core concepts, techniques, and intuition needed to solve these types of problems.

I've included a checklist that you can use to work through the list below:

#### Array

- [X] Two Sum - [https://leetcode.com/problems/two-sum/](https://leetcode.com/problems/two-sum/)
- [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/)
- [X] Contains Duplicate - [https://leetcode.com/problems/contains-duplicate/](https://leetcode.com/problems/contains-duplicate/)
- [X] Product of Array Except Self - [https://leetcode.com/problems/product-of-array-except-self/](https://leetcode.com/problems/product-of-array-except-self/)
- [X] Maximum Subarray - [https://leetcode.com/problems/maximum-subarray/](https://leetcode.com/problems/maximum-subarray/)
- [X] Maximum Product Subarray - [https://leetcode.com/problems/maximum-product-subarray/](https://leetcode.com/problems/maximum-product-subarray/)
- [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/)
- [X] Search in Rotated Sorted Array - [https://leetcode.com/problems/search-in-rotated-sorted-array/](https://leetcode.com/problems/search-in-rotated-sorted-array/)
- [X] 3Sum - [https://leetcode.com/problems/3sum/](https://leetcode.com/problems/3sum/)
- [X] Container With Most Water - [https://leetcode.com/problems/container-with-most-water/](https://leetcode.com/problems/container-with-most-water/)

---

#### Binary

- [X] Sum of Two Integers - [https://leetcode.com/problems/sum-of-two-integers/](https://leetcode.com/problems/sum-of-two-integers/)
- [X] Number of 1 Bits - [https://leetcode.com/problems/number-of-1-bits/](https://leetcode.com/problems/number-of-1-bits/)
- [X] Counting Bits - [https://leetcode.com/problems/counting-bits/](https://leetcode.com/problems/counting-bits/)
- [X] Missing Number - [https://leetcode.com/problems/missing-number/](https://leetcode.com/problems/missing-number/)
- [X] Reverse Bits - [https://leetcode.com/problems/reverse-bits/](https://leetcode.com/problems/reverse-bits/)

---

#### Dynamic Programming

- [X] Climbing Stairs - [https://leetcode.com/problems/climbing-stairs/](https://leetcode.com/problems/climbing-stairs/)
- [X] Coin Change - [https://leetcode.com/problems/coin-change/](https://leetcode.com/problems/coin-change/)
- [X] Longest Increasing Subsequence - [https://leetcode.com/problems/longest-increasing-subsequence/](https://leetcode.com/problems/longest-increasing-subsequence/)
- [X] Longest Common Subsequence - [https://leetcode.com/problems/longest-common-subsequence/](https://leetcode.com/problems/longest-common-subsequence/)
- [X] Word Break Problem - [https://leetcode.com/problems/word-break/](https://leetcode.com/problems/word-break/)
- [X] Combination Sum - [https://leetcode.com/problems/combination-sum-iv/](https://leetcode.com/problems/combination-sum-iv/)
- [X] House Robber - [https://leetcode.com/problems/house-robber/](https://leetcode.com/problems/house-robber/)
- [X] House Robber II - [https://leetcode.com/problems/house-robber-ii/](https://leetcode.com/problems/house-robber-ii/)
- [X] Decode Ways - [https://leetcode.com/problems/decode-ways/](https://leetcode.com/problems/decode-ways/)
- [X] Unique Paths - [https://leetcode.com/problems/unique-paths/](https://leetcode.com/problems/unique-paths/)
- [X] Jump Game - [https://leetcode.com/problems/jump-game/](https://leetcode.com/problems/jump-game/)

---

#### Graph

- [X] Clone Graph - [https://leetcode.com/problems/clone-graph/](https://leetcode.com/problems/clone-graph/)
- [X] Course Schedule - [https://leetcode.com/problems/course-schedule/](https://leetcode.com/problems/course-schedule/)
- [X] Pacific Atlantic Water Flow - [https://leetcode.com/problems/pacific-atlantic-water-flow/](https://leetcode.com/problems/pacific-atlantic-water-flow/)
- [X] Number of Islands - [https://leetcode.com/problems/number-of-islands/](https://leetcode.com/problems/number-of-islands/)
- [X] Longest Consecutive Sequence - [https://leetcode.com/problems/longest-consecutive-sequence/](https://leetcode.com/problems/longest-consecutive-sequence/)
- [X] Alien Dictionary (Leetcode Premium) - [https://leetcode.com/problems/alien-dictionary/](https://leetcode.com/problems/alien-dictionary/)
- [X] Graph Valid Tree (Leetcode Premium) - [https://leetcode.com/problems/graph-valid-tree/](https://leetcode.com/problems/graph-valid-tree/)
- [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/)

---

#### Interval

- [X] Insert Interval - [https://leetcode.com/problems/insert-interval/](https://leetcode.com/problems/insert-interval/)
- [X] Merge Intervals - [https://leetcode.com/problems/merge-intervals/](https://leetcode.com/problems/merge-intervals/)
- [X] Non-overlapping Intervals - [https://leetcode.com/problems/non-overlapping-intervals/](https://leetcode.com/problems/non-overlapping-intervals/)
- [X] Meeting Rooms (Leetcode Premium) - [https://leetcode.com/problems/meeting-rooms/](https://leetcode.com/problems/meeting-rooms/)
- [X] Meeting Rooms II (Leetcode Premium) - [https://leetcode.com/problems/meeting-rooms-ii/](https://leetcode.com/problems/meeting-rooms-ii/)

---

#### Linked List

- [X] Reverse a Linked List - [https://leetcode.com/problems/reverse-linked-list/](https://leetcode.com/problems/reverse-linked-list/)
- [X] Detect Cycle in a Linked List - [https://leetcode.com/problems/linked-list-cycle/](https://leetcode.com/problems/linked-list-cycle/)
- [X] Merge Two Sorted Lists - [https://leetcode.com/problems/merge-two-sorted-lists/](https://leetcode.com/problems/merge-two-sorted-lists/)
- [X] Merge K Sorted Lists - [https://leetcode.com/problems/merge-k-sorted-lists/](https://leetcode.com/problems/merge-k-sorted-lists/)
- [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/)
- [X] Reorder List - [https://leetcode.com/problems/reorder-list/](https://leetcode.com/problems/reorder-list/)

---

#### Matrix

- [X] Set Matrix Zeroes - [https://leetcode.com/problems/set-matrix-zeroes/](https://leetcode.com/problems/set-matrix-zeroes/)
- [X] Spiral Matrix - [https://leetcode.com/problems/spiral-matrix/](https://leetcode.com/problems/spiral-matrix/)
- [X] Rotate Image - [https://leetcode.com/problems/rotate-image/](https://leetcode.com/problems/rotate-image/)
- [X] Word Search - [https://leetcode.com/problems/word-search/](https://leetcode.com/problems/word-search/)

---

#### String

- [X] Longest Substring Without Repeating Characters - [https://leetcode.com/problems/longest-substring-without-repeating-characters/](https://leetcode.com/problems/longest-substring-without-repeating-characters/)
- [X] Longest Repeating Character Replacement - [https://leetcode.com/problems/longest-repeating-character-replacement/](https://leetcode.com/problems/longest-repeating-character-replacement/)
- [X] Minimum Window Substring - [https://leetcode.com/problems/minimum-window-substring/](https://leetcode.com/problems/minimum-window-substring/)
- [X] Valid Anagram - [https://leetcode.com/problems/valid-anagram/](https://leetcode.com/problems/valid-anagram/)
- [X] Group Anagrams - [https://leetcode.com/problems/group-anagrams/](https://leetcode.com/problems/group-anagrams/)
- [X] Valid Parentheses - [https://leetcode.com/problems/valid-parentheses/](https://leetcode.com/problems/valid-parentheses/)
- [X] Valid Palindrome - [https://leetcode.com/problems/valid-palindrome/](https://leetcode.com/problems/valid-palindrome/)
- [X] Longest Palindromic Substring - [https://leetcode.com/problems/longest-palindromic-substring/](https://leetcode.com/problems/longest-palindromic-substring/)
- [X] Palindromic Substrings - [https://leetcode.com/problems/palindromic-substrings/](https://leetcode.com/problems/palindromic-substrings/)
- [X] Encode and Decode Strings (Leetcode Premium) - [https://leetcode.com/problems/encode-and-decode-strings/](https://leetcode.com/problems/encode-and-decode-strings/)

---

#### Tree

- [X] Maximum Depth of Binary Tree - [https://leetcode.com/problems/maximum-depth-of-binary-tree/](https://leetcode.com/problems/maximum-depth-of-binary-tree/)
- [X] Same Tree - [https://leetcode.com/problems/same-tree/](https://leetcode.com/problems/same-tree/)
- [X] Invert/Flip Binary Tree - [https://leetcode.com/problems/invert-binary-tree/](https://leetcode.com/problems/invert-binary-tree/)
- [X] Binary Tree Maximum Path Sum - [https://leetcode.com/problems/binary-tree-maximum-path-sum/](https://leetcode.com/problems/binary-tree-maximum-path-sum/)
- [X] Binary Tree Level Order Traversal - [https://leetcode.com/problems/binary-tree-level-order-traversal/](https://leetcode.com/problems/binary-tree-level-order-traversal/)
- [X] Serialize and Deserialize Binary Tree - [https://leetcode.com/problems/serialize-and-deserialize-binary-tree/](https://leetcode.com/problems/serialize-and-deserialize-binary-tree/)
- [X] Subtree of Another Tree - [https://leetcode.com/problems/subtree-of-another-tree/](https://leetcode.com/problems/subtree-of-another-tree/)
- [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/)
- [X] Validate Binary Search Tree - [https://leetcode.com/problems/validate-binary-search-tree/](https://leetcode.com/problems/validate-binary-search-tree/)
- [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/)
- [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/)
- [X] Implement Trie (Prefix Tree) - [https://leetcode.com/problems/implement-trie-prefix-tree/](https://leetcode.com/problems/implement-trie-prefix-tree/)
- [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/)
- [X] Word Search II - [https://leetcode.com/problems/word-search-ii/](https://leetcode.com/problems/word-search-ii/)

---

#### Heap

- [X] Merge K Sorted Lists - [https://leetcode.com/problems/merge-k-sorted-lists/](https://leetcode.com/problems/merge-k-sorted-lists/)
- [X] Top K Frequent Elements - [https://leetcode.com/problems/top-k-frequent-elements/](https://leetcode.com/problems/top-k-frequent-elements/)
- [X] Find Median from Data Stream - [https://leetcode.com/problems/find-median-from-data-stream/](https://leetcode.com/problems/find-median-from-data-stream/)