Skip to content

Commit d4ceff1

Browse files
committedSep 8, 2023
feat: add example for reorder list in main
1 parent d7f46cd commit d4ceff1

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed
 

‎Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9+
10+
[profile.dev]
11+
debug = true
12+
13+
[profile.release]
14+
debug = false

‎src/main.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
mod easy;
1+
mod medium;
2+
3+
use medium::reorder_list::ListNode;
24

35
fn main() {
6+
// Reorder List - Medium
7+
let mut head = Some(Box::new(
8+
ListNode::new(1).add_next(
9+
ListNode::new(2)
10+
.add_next(ListNode::new(3).add_next(ListNode::new(4).add_next(ListNode::new(5)))),
11+
),
12+
));
413

5-
// Roman to Interger
6-
let s = String::from("III");
7-
let result = easy::roman_to_integer::roman_to_int(s);
8-
println!("result: {}", result);
14+
medium::reorder_list::reorder_list(&mut head);
915

10-
// Longest Common Prefix
11-
let strs = vec![String::from("flower"), String::from("flow"), String::from("flight")];
12-
let result = easy::longest_common_prefix::longest_common_prefix(strs);
13-
println!("result: {}", result);
14-
16+
// Print elements of the list
17+
let mut curr = head;
18+
while let Some(node) = curr {
19+
println!("{}", node.val);
20+
curr = node.next;
21+
}
1522
}

0 commit comments

Comments
 (0)
Please sign in to comment.