A comprehensive collection of LeetCode problem solutions implemented in Rust.
This repository contains Rust solutions for over 500 LeetCode problems. Each solution is implemented with a focus on:
- Clean, idiomatic Rust code
- Detailed documentation and comments
- Optimal time and space complexity
- Test cases where applicable
Solutions are organized by problem number and title:
0001.Two Sum.rs0002.Add Two Numbers.rs- etc.
Each file contains:
- The solution implementation
- Documentation comments explaining the approach
- Time and space complexity analysis (in most solutions)
- Test cases for validation
These solutions can be used as:
- Reference for learning Rust programming patterns
- Study material for algorithm and data structure concepts
- Preparation for coding interviews
- Examples of idiomatic Rust code
To run any solution locally:
- Make sure you have Rust installed (https://www.rust-lang.org/tools/install)
- Create a new Rust project:
cargo new leetcode_solution - Replace the content of
src/main.rswith the solution code - Add any necessary dependencies to
Cargo.toml - Run with
cargo run
Contributions are welcome! If you'd like to add a new solution or improve an existing one:
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to LeetCode for providing the problems
- The Rust community for creating such an amazing language