This repository contains solutions to LeetCode problems implemented in Dart, with a focus on clean code, performance tracking, and comprehensive documentation.
- Dart SDK >=3.1.0
- Git
- Clone the repository
git clone https://github.com/yourusername/leetcode-dart.git
cd leetcode-dart- Install dependencies
dart pub get- Run a solution with performance metrics
dart run src/two_sum.dart --enable-vm-service- Create a new file in the appropriate category folder:
mkdir -p src/category_name
touch src/category_name/problem_name.dart- Use the standard header template:
/ ==========================================
Problem Number. Problem Name
==========================================
Category: Your Categories
Difficulty: Easy/Medium/Hard
Problem Description
==========================================
Copy the problem description here...
Examples
==========================================
Example 1:
Input: ...
Output: ...
Constraints
==========================================
List constraints...
Approach
==========================================
Explain your approach...
Time Complexity: O(...)
Space Complexity: O(...)
/- Implement your solution with the Utils class:
import '../utils.dart';
class Solution {
// Your solution here
}
void main() {
final solution = Solution();
Utils.runTimer('Problem Name', () {
return solution.methodName(input);
});
}The Utils class provides performance metrics for each solution:
- Execution time
- Memory usage
- Result validation
Run solutions with the VM service flag to get memory metrics:
dart run src/your_solution.dart --enable-vm-serviceleetcode-dart/
├── src/ # Solutions by category
│ ├── arrays/ # Array-based problems
│ ├── bfs/ # Breadth-First Search
│ ├── dfs/ # Depth-First Search
│ ├── dp/ # Dynamic Programming
│ ├── sliding_window/# Sliding Window
│ ├── two_pointers/ # Two Pointers
│ └── utils.dart # Performance tracking utilities
├── test/ # Test cases (coming soon)
└── README.md # Documentation
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingSolution) - Commit your changes (
git commit -m 'Add solution for Problem X') - Push to the branch (
git push origin feature/AmazingSolution) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.