This repository contains my solutions to LeetCode problems implemented in Go, organized by algorithmic patterns.
leetcode-go/
├── problems/ # Problem solutions organized by algorithmic patterns
│ ├── array/ # Array manipulation problems
│ ├── hash-table/ # Hash table/map-based solutions
│ ├── two-pointers/ # Two pointer technique
│ ├── sliding-window/ # Sliding window problems
│ ├── binary-search/ # Binary search problems
│ ├── dynamic-programming/ # DP problems
│ ├── backtracking/ # Backtracking problems
│ ├── greedy/ # Greedy algorithm problems
│ ├── graph/ # Graph traversal problems
│ ├── tree/ # Tree problems (BST, binary tree, etc.)
│ ├── string/ # String manipulation problems
│ ├── linked-list/ # Linked list problems
│ ├── stack/ # Stack-based problems
│ ├── queue/ # Queue-based problems
│ ├── heap/ # Heap/priority queue problems
│ ├── trie/ # Trie problems
│ ├── union-find/ # Union-Find/Disjoint Set problems
│ └── bit-manipulation/ # Bit manipulation problems
├── utils/ # Common utilities and helper functions
└── go.mod # Go module file
Problems that use hash maps/sets for O(1) lookups and tracking.
- Example: Two Sum, Group Anagrams, Longest Substring Without Repeating Characters
Problems solved using two pointers moving through the array/string.
- Example: Valid Palindrome, Container With Most Water, 3Sum
Problems involving contiguous subarrays/substrings with a window.
- Example: Maximum Average Subarray, Minimum Window Substring
Problems that can be solved using binary search on sorted arrays or search spaces.
- Example: Search in Rotated Sorted Array, Find Peak Element
Problems that can be broken down into overlapping subproblems.
- Example: Climbing Stairs, Coin Change, Longest Common Subsequence
Problems that require exploring all possible solutions.
- Example: N-Queens, Generate Parentheses, Word Search
Problems solved by making locally optimal choices.
- Example: Jump Game, Gas Station, Meeting Rooms
Problems involving graph traversal (BFS/DFS) and algorithms.
- Example: Number of Islands, Course Schedule, Clone Graph
Problems involving tree data structures and tree traversal.
- Example: Maximum Depth of Binary Tree, Validate BST, Invert Binary Tree
- Identify the algorithmic pattern for your problem
- Create a new problem directory under the appropriate pattern folder:
problems/[pattern]/[problem-id]-[problem-name]/ - Implement the solution in
solution.go - Add tests in
solution_test.go - Run tests:
go test ./problems/[pattern]/[problem-id]-[problem-name]
To solve problem "Two Sum" (problem #1) which uses Hash Table pattern:
- Directory:
problems/hash-table/1-two-sum/ - Files:
solution.goandsolution_test.go - Run:
go test ./problems/hash-table/1-two-sum