You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
High-performance Go solutions to LeetCode problems with optimal algorithms and Go best practices.
Overview
This repository contains 150 LeetCode problems solved in Go, covering all major algorithm categories from Easy to Hard difficulty levels. Each solution is optimized for performance and follows Go best practices with comprehensive test coverage.
Optimal Algorithms: Best time/space complexity solutions
Go Best Practices: Modern Go 1.24+ patterns and idioms
Performance Focused: Zero-allocation patterns and optimizations
Complete Testing: 100% test coverage with benchmarks
Comprehensive Documentation: Detailed explanations for each solution
Consistent Structure: Uniform project organization across all problems
Up-to-Date: Includes recent problems up to #3539
Quick Start
# Clone the repository
git clone https://github.com/yourusername/go-leetcode-master.git
cd go-leetcode-master
# Run tests for a specific problemcd two_sum_1
go test -v -bench=. -benchmem
# Run all tests
make test# Run benchmarks
make bench
# Check test coverage
make cover_html
Project Structure
Each problem follows a consistent directory structure:
problem_name_number/
├── README.md # Problem description and approach
├── solution.go # Optimized Go solution
└── solution_test.go # Comprehensive tests and benchmarks
Build System:
Makefile - Build automation and testing
go.mod - Go module with dependencies (testify v1.5.1)
This repository emphasizes comprehensive testing and performance analysis:
Test Coverage
100% test coverage across all 150 problems
Unit tests for all edge cases and example inputs
Benchmark tests for performance analysis
Memory allocation tracking with -benchmem
Available Make Commands
# Run all tests with coverage
make test# Run tests with verbose output
make test_v
# Run benchmarks for all problems
make bench
# Generate coverage report (HTML)
make cover_html
# Generate coverage report (function level)
make cover_func
# Format all Go code
make fmt
# Run Go vet for code quality
make vet
# Count total lines of code
make loc
# Count total problems solved
make solved
Test Dependencies
testify v1.5.1 - Testing framework for assertions and test suites
Built-in Go testing tools for benchmarks and coverage
Contributing
Fork the repository
Create a feature branch (git checkout -b feature/new-solution)
Add your solution following the existing structure:
Create a directory named problem_name_number/
Add solution.go with the implementation
Add solution_test.go with comprehensive tests
Add README.md with problem description and approach
Ensure all tests pass and benchmarks are included
Submit a pull request
Code Quality Standards
Follow Go best practices and idioms
Use meaningful variable and function names
Include comprehensive test cases
Add benchmarks for performance-critical solutions
Document complex algorithms with comments
Repository Highlights
Problem Range
Classic Problems: Two Sum (#1), Valid Parentheses (#20), Merge Two Sorted Lists (#21)
Recent Challenges: Problems up to #3539 showing active maintenance
Concurrency: Go-specific concurrency problems with goroutines and channels
Algorithm Categories Covered
✅ 22 Major Categories including Arrays, Dynamic Programming, Graphs, Trees, and more
✅ Advanced Graph Algorithms like Tarjan's Algorithm and Convex Hull
✅ Concurrency Patterns unique to Go programming
✅ Mathematical Algorithms for geometry and combinatorics
✅ String Processing with pattern matching and manipulation
✅ Design Problems including LRU Cache and data structures
Performance Focus
Zero-allocation patterns where possible
Optimal time complexity solutions prioritized
Memory-efficient implementations with detailed benchmarks
Real-world performance considerations
License
This project is licensed under the MIT License - see the LICENSE file for details.
Total Problems Solved: 150 | Go Version: 1.24+ | Last Updated: 2025