A collection of solutions to LeetCode problems, primarily focusing on Go and SQL implementations. More language solutions are planned for the future.
├── README.md
├── go
│ ├── cmd
│ ├── go.mod
│ ├── sample workouts
│ └── solutions
│ └── # Contains all Go solutions
└── sql
The repository contains solutions to various LeetCode problems, including:
- Two Sum (#1)
- Longest Common Prefix (#14)
- Valid Parentheses (#20)
- Group Anagrams (#49)
- Matrix Diagonal Sum (#1572)
- Transpose Matrix (#867)
- and more...
- Symmetric Tree (#101)
- Maximum Depth of Binary Tree (#104)
- Binary Tree Inorder Traversal (#94)
- Invert Binary Tree (#226)
- Kth Smallest Element in a BST (#230)
- and more...
- Merge Two Sorted Lists (#21)
- Reverse Linked List (#206)
- and more...
- Fibonacci Number (#509)
- Range Sum Query (#303)
- and more...
- Implement Trie (#208)
- Valid Anagram (#242)
- and more...
Each solution includes:
- Problem description with constraints
- Multiple solution approaches where applicable
- Time and space complexity analysis
- Example test cases
Here's a sample solution for the Two Sum problem:
func twoSum(nums []int, target int) []int {
if len(nums) == 2 {
return []int{0,1}
}
h := make(map[int]int, len(nums))
for i, num := range nums {
t := target - num
if _, ok := h[t]; ok {
return []int{h[t], i}
}
h[num] = i
}
return []int{}
}
- Clone the repository:
git clone https://github.com/abdullahnettoor/leetcode
- Navigate to the project directory:
cd leetcode/go
- Run a specific solution:
go run cmd/main.go
Contributions are welcome! Feel free to:
- Add new solutions
- Improve existing solutions
- Add solutions in different programming languages
- Improve documentation
This project is open source and available under the MIT License.
Created by @abdullahnettoor