#macro

leetcode_prelude

Some useful macros and definition for exercising in leetcode

5 releases

0.2.3 Aug 14, 2020
0.2.2 Feb 14, 2019
0.1.2 Dec 29, 2018
0.1.1 Dec 29, 2018
0.1.0 Dec 29, 2018

#678 in Rust patterns

Download history 43/week @ 2022-08-13 29/week @ 2022-08-20 20/week @ 2022-08-27 40/week @ 2022-09-03 49/week @ 2022-09-10 26/week @ 2022-09-17 21/week @ 2022-09-24 57/week @ 2022-10-01 42/week @ 2022-10-08 18/week @ 2022-10-15 20/week @ 2022-10-22 51/week @ 2022-10-29 61/week @ 2022-11-05 35/week @ 2022-11-12 37/week @ 2022-11-19 16/week @ 2022-11-26

163 downloads per month

MIT license

8KB
147 lines

leetcode_prelude

Some useful macros and definition for exercising in LeetCode.

How to use

Add following lines to your Cargo.toml.

[dependencies]
leetcode_prelude = "^0.2"

Examples

Binary tree initialization

use leetcode_prelude::btree;

let btree = btree![1, 2, 2, null, null, 3, 3];

Linked list initialization

use leetcode_prelude::linkedlist;

let linkedlist = linkedlist![1, 2, 3];

Generate test code from leetcode's json

use leetcode_prelude::leetcode_test;

leetcode_test!(
     ["Trie", "insert", "search"]
     [[], ["apple"], ["apple"]]
     [null, null, true]
)

Create a Vec<String>

use leetcode_prelude::vec_string;

let vec = vec_string!["1", "2", "3"];

assert_eq_sorted

use leetcode_prelude::assert_eq_sorted;

assert_eq_sorted!(vec![1, 2], vec![2, 1]);

Dependencies

~405–670KB
~15K SLoC