A comprehensive collection of 105 LeetCode solutions in Rust, featuring multiple algorithmic approaches, extensive testing, performance benchmarking, and interactive problem exploration tools.
- 105 unique problems across all difficulty levels
- Multiple approaches per problem (2-6 implementations each)
- Detailed complexity analysis for every solution
- 100% test pass rate with comprehensive test suites
- Interactive Problem Selector - Navigate problems by difficulty, topic, or complexity
- Performance Benchmarking Suite - Compare algorithmic approaches with real metrics
- Complexity Analysis Guide - Deep dive into time/space trade-offs
- Difficulty Analysis Report - Learning path recommendations and pattern recognition
- Clean, idiomatic Rust code with comprehensive documentation
- Property-based testing using proptest for edge case discovery
- Criterion.rs benchmarking for performance validation
- Zero unsafe code with comprehensive linting
- Rust 1.75 or later
- Cargo (comes with Rust)
git clone https://github.com/your-username/rust-leetcode.git
cd rust-leetcode
cargo build
# Run all tests
cargo test
# Run tests for specific problem
cargo test two_sum
# Run with coverage
cargo install cargo-tarpaulin
cargo tarpaulin --out Html
# Launch interactive problem browser
cargo run --bin problem-selector
# Track your learning progress
cargo run --bin progress-tracker
# Practice coding interviews
cargo run --bin interview-simulator
# Generate solution templates for new problems
cargo run --bin solution-generator
# Fetch and add new problems automatically (NEW!)
cargo run --bin problem-fetcher
# Test LeetCode API integration
cargo run --bin api-demo
# Run all benchmarks
cargo bench
# Benchmark specific problems
cargo bench two_sum
cargo bench -- --save-baseline main
rust-leetcode/
├── 📁 src/
│ ├── 📁 easy/ # Easy difficulty problems (14)
│ ├── 📁 medium/ # Medium difficulty problems (45)
│ ├── 📁 hard/ # Hard difficulty problems (46)
│ ├── 📁 utils/ # Common data structures & helpers
│ └── 📁 bin/ # Interactive tools
├── 📁 benches/ # Performance benchmarks
├── 📁 tests/ # Integration tests
├── 📁 docs/ # Additional documentation
├── 📊 DIFFICULTY_ANALYSIS.md # Problem analysis & learning paths
├── ⚡ PERFORMANCE_REPORT.md # Benchmark results & insights
├── 🔍 COMPLEXITY_GUIDE.md # Complexity analysis guide
├── 🎯 ALGORITHM_PATTERNS.md # Master essential algorithmic patterns
├── 📋 LEETCODE_PROBLEMS.md # Complete problem reference
├── 🚀 FEATURE_OVERVIEW.md # Complete platform capabilities guide
└── 🛠️ DEVELOPMENT_GUIDE.md # Advanced development and contribution guide
The repository includes a comprehensive suite of interactive tools to enhance your learning experience:
cargo run --bin problem-selector
- Browse by difficulty, topic, and complexity
- Get random problems for practice
- Follow structured learning paths
- View detailed problem information and statistics
cargo run --bin progress-tracker
- Track completion status across all 105 problems
- Monitor progress by difficulty and algorithmic patterns
- Get personalized problem recommendations
- Export detailed progress reports
- Set and track learning goals
cargo run --bin interview-simulator
- Practice under realistic interview conditions
- Multiple session types: Phone Screen, Technical Round, On-site
- Real-time performance feedback and analysis
- Post-interview improvement recommendations
- Timed sessions with interactive interviewer responses
cargo run --bin solution-generator
- Generate boilerplate for new LeetCode problems
- Multiple solution approach templates
- Comprehensive test suite generation
- Automatic benchmark integration
- Documentation and complexity analysis templates
Difficulty | Count | Percentage | Example Problems |
---|---|---|---|
Easy | 14 | 13.3% | Two Sum, Valid Parentheses, Climbing Stairs |
Medium | 45 | 42.9% | 3Sum, LRU Cache, Number of Islands |
Hard | 46 | 43.8% | Median Arrays, Edit Distance, Regex Matching |
- Dynamic Programming: 25 problems
- Tree & Graph Algorithms: 20 problems
- Array & String Processing: 18 problems
- Hash Tables & Maps: 15 problems
- Two Pointers & Sliding Window: 12 problems
pub fn two_sum(&self, nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut map: HashMap<i32, usize> = HashMap::new();
for (i, &num) in nums.iter().enumerate() {
let complement = target - num;
if let Some(&complement_index) = map.get(&complement) {
return vec![complement_index as i32, i as i32];
}
map.insert(num, i);
}
vec![]
}
Complexity: O(n) time, O(n) space
pub fn length_of_longest_substring(&self, s: String) -> i32 {
let chars: Vec<char> = s.chars().collect();
let mut char_index = HashMap::new();
let mut max_len = 0;
let mut start = 0;
for (end, &ch) in chars.iter().enumerate() {
if let Some(&idx) = char_index.get(&ch) {
start = start.max(idx + 1);
}
char_index.insert(ch, end);
max_len = max_len.max(end - start + 1);
}
max_len as i32
}
Complexity: O(n) time, O(min(m,n)) space
pub fn find_median_sorted_arrays(&self, nums1: Vec<i32>, nums2: Vec<i32>) -> f64 {
let (nums1, nums2) = if nums1.len() > nums2.len() {
(nums2, nums1)
} else {
(nums1, nums2)
};
let m = nums1.len();
let n = nums2.len();
let total_left = (m + n + 1) / 2;
let mut left = 0;
let mut right = m;
while left <= right {
let cut1 = (left + right) / 2;
let cut2 = total_left - cut1;
let left1 = if cut1 == 0 { i32::MIN } else { nums1[cut1 - 1] };
let left2 = if cut2 == 0 { i32::MIN } else { nums2[cut2 - 1] };
let right1 = if cut1 == m { i32::MAX } else { nums1[cut1] };
let right2 = if cut2 == n { i32::MAX } else { nums2[cut2] };
if left1 <= right2 && left2 <= right1 {
return if (m + n) % 2 == 1 {
left1.max(left2) as f64
} else {
(left1.max(left2) + right1.min(right2)) as f64 / 2.0
};
} else if left1 > right2 {
right = cut1 - 1;
} else {
left = cut1 + 1;
}
}
-1.0
}
Complexity: O(log(min(m,n))) time, O(1) space
The repository includes comprehensive benchmarks comparing different algorithmic approaches:
Input Size 1000:
Hash Map: 847.23 µs (Optimal)
Two Pass: 1.2034 ms (1.4x slower)
Brute Force: 47.234 ms (55.7x slower)
Longest Substring (10k chars):
Sliding Window: 245.67 µs (Optimal)
Hash Set: 312.89 µs (1.3x slower)
Brute Force: 127.2 ms (518x slower)
Run benchmarks yourself:
cargo bench # All benchmarks
cargo bench two_sum # Specific problem
cargo bench -- --save-baseline main # Save baseline
Perfect for interview preparation and algorithm fundamentals:
- Two Sum - Hash table basics
- Valid Parentheses - Stack operations
- Merge Two Sorted Lists - Linked list manipulation
- Maximum Depth of Binary Tree - Tree traversal
- Climbing Stairs - Dynamic programming introduction
Advanced patterns and optimization techniques:
- 3Sum - Two pointers technique
- Longest Substring Without Repeating - Sliding window
- Number of Islands - DFS/BFS graph traversal
- LRU Cache - System design fundamentals
- Maximum Subarray - Kadane's algorithm
Complex algorithms and system design:
- Median of Two Sorted Arrays - Binary search mastery
- Edit Distance - Complex dynamic programming
- Trapping Rain Water - Multiple solution approaches
- Regular Expression Matching - Advanced pattern matching
- Merge k Sorted Lists - Divide and conquer optimization
# Format code
cargo fmt
# Run lints
cargo clippy -- -D warnings
# Check for unused dependencies
cargo machete
# Security audit
cargo audit
# Unit tests
cargo test
# Integration tests
cargo test --test integration_tests
# Property-based tests
cargo test --test property_tests
# Test with coverage
cargo tarpaulin --out Html --output-dir coverage/
# Generate docs
cargo doc --open
# Run doc tests
cargo test --doc
# Check doc coverage
cargo +nightly rustdoc -- --show-coverage
- Algorithm Patterns Guide - Master 10 essential algorithmic patterns with templates and examples
- Difficulty Analysis - Comprehensive problem analysis and learning recommendations
- Complexity Guide - Deep dive into time/space complexity analysis
- Problem Reference - Complete problem list with status indicators
- Feature Overview - Complete guide to all platform capabilities and use cases
- Development Guide - Advanced development workflows and contribution guidelines
- Performance Report - Benchmark results and algorithmic insights
- Test Coverage Report - Detailed testing analysis
- Benchmark Results - Performance comparison data
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Follow Rust formatting conventions (
cargo fmt
) - Add comprehensive tests for new solutions
- Include multiple approaches when applicable
- Update documentation and benchmarks
- Ensure all tests pass (
cargo test
)
- Total Problems: 105 unique implementations
- Total Test Cases: 1,430 (100% passing)
- Solution Approaches: 280+ different implementations
- Code Coverage: 100% line coverage
- Benchmark Coverage: 8 comprehensive benchmark suites
- Documentation: 95%+ doc coverage
✅ 100% Test Success Rate - All 1,430 tests passing
✅ Zero Unsafe Code - Memory-safe implementations throughout
✅ Comprehensive Benchmarking - Performance validation for all major algorithms
✅ Multiple Approaches - 2-6 implementations per problem with complexity analysis
✅ Interactive Tools - Problem selector and analysis utilities
✅ Complete Documentation - In-depth guides and analysis reports
- Rust - Systems programming language
- Criterion.rs - Statistical benchmarking
- Proptest - Property-based testing
- Tarpaulin - Code coverage analysis
This project is licensed under the MIT License - see the LICENSE file for details.
Marvin Tutt
Caia Tech
Built with Rust 🦀 for learning, interview preparation, and AI training
⭐ Found this helpful? Give it a star and share with fellow developers!
🚀 Ready to get started? Choose your path:
- Explore Problems:
cargo run --bin problem-selector
- Track Progress:
cargo run --bin progress-tracker
- Practice Interviews:
cargo run --bin interview-simulator
- Generate Templates:
cargo run --bin solution-generator