https://github.com/sidvishnoi/leetcode-rust
LeetCode Solutions in Rust
https://github.com/sidvishnoi/leetcode-rust
leetcode-rust leetcode-solutions
Last synced: 7 months ago
JSON representation
LeetCode Solutions in Rust
- Host: GitHub
- URL: https://github.com/sidvishnoi/leetcode-rust
- Owner: sidvishnoi
- Created: 2020-07-24T18:16:26.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-27T13:19:23.000Z (almost 5 years ago)
- Last Synced: 2025-02-09T12:29:40.690Z (9 months ago)
- Topics: leetcode-rust, leetcode-solutions
- Language: Rust
- Homepage:
- Size: 272 KB
- Stars: 1
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LeetCode Solutions in Rust
**Why would I solve LeetCode problems in Rust?!** I wanted to learn Rust, without committing myself to some large real-world project. LeetCode monthly challenges are good for consistently practicing.
**Why would someone not use Rust for LeetCode problems?** Mainly because of the learning curve. It's a little difficult to successfully run a Rust program in one go unlike other common languages. You don't want to fight the borrow checker in a contest. Also, C++/Java/Python/JavaScript are more expressive to quickly solve these problems.
## Running
Most of the solutions here are self contained programs. I did not use cargo because I wanted to keep it real simple.
You can copy paste a code and run it online in [Rust Playground](https://play.rust-lang.org/).
To run locally:
```bash
rustc 1234-some-file.rs -g -o run
./run
```
### With VS Code
Run the default build task to compile and run:
1. Ctrl+Shift+p
2. Select: "Tasks: Run build task".
Pro tip: Assign a keyboard shortcut to the default build task. I use Ctrl+Shift+B.
Set the backtrace level in tasks.json, if needed.
There is also a "test" task for formatting the code with `rustfmt`. I've assigned it to Ctrl+Shift+V.