11 releases
0.1.132 | Mar 21, 2024 |
---|---|
0.1.131 | Mar 21, 2024 |
#597 in Data structures
492 downloads per month
7KB
LeetCode Trees in Rust
This library is made to make any LeetCoders using Rust have a better experience
at solving their LeetCode (LC) problems. It uses cargo make to have
reproducible sub modules (check leetcode-trees-rs/solutions/README.md
) as
well as implementing the definition of the binary trees on LC.
Quick start on using the library:
use leetcode_trees_rs::{prelude::*, utils::TreeNode}; // Importing the library.
struct Solution {} // Assigning an empty struct to make a solution impl block.
use std::{cell::RefCell, rc::Rc};
impl Solution {
pub fn your_leetcode_fn() {}
}
fn main() -> Result<()> {
// Your testing here . . .
// Alternatively, you can just use functions with #[test] definitions.
Ok(())
}
Additional code templating can be found in This template file.
It's located at: solutions/lc0_general_nodes_template/src/main.rs
lib.rs
:
Introduction
LeetCode Trees's purpose is making LeetCode problems easier to work around with via some simple library exports that allow for a smoother development experience by allowing you to use your primary IDE rather than the LeetCode website to solve the problems.
Installation
These are the two ways to can add this library to your project:
Number 1 - Via the Cargo.toml
file by adding this;
[dependencies]
leetcode-trees-rs = "0.1"
Number 2 - Via running the following command in your terminal:
cargo add leetcode-trees-rs
Usage
The usage is very simple. These are the primary components:
Additionally, via the support of the cargo make library you can comfortably run your LeetCode tests by running:
cargo make leetcode_problem_number
Assuming there's a LeetCode submittion for it. All the solutions are managed on the GitHub page of this libray.
Dependencies
~33–49MB
~696K SLoC