#leetcode #tree-node #binary-tree #problem #solution #library #import

leetcode-trees-rs

A Rust library for Tree Node LeetCode problems

15 releases

new 0.1.144 May 12, 2024
0.1.143 May 12, 2024
0.1.132 Mar 21, 2024

#178 in Memory management

Download history 584/week @ 2024-03-18 110/week @ 2024-04-01 144/week @ 2024-05-06

144 downloads per month

MIT license

31KB
319 lines

LeetCode Trees in Rust

Build StatusLatest Version

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 features:

  • Singly Linked Lists (example Leet - add two numbers)

  • Macros (for Trees and Linked Lists)

Additional code templating can be found in This template file. It's located at: solutions/lc0_general_nodes_template/src/main.rs

Dependencies

~33–46MB
~684K SLoC