Skip to content

Commit

Permalink
feat: add example for reorder list in main
Browse files Browse the repository at this point in the history
  • Loading branch information
bujosa committed Sep 8, 2023
1 parent d7f46cd commit d4ceff1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[profile.dev]
debug = true

[profile.release]
debug = false
27 changes: 17 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
mod easy;
mod medium;

use medium::reorder_list::ListNode;

fn main() {
// Reorder List - Medium
let mut head = Some(Box::new(
ListNode::new(1).add_next(
ListNode::new(2)
.add_next(ListNode::new(3).add_next(ListNode::new(4).add_next(ListNode::new(5)))),
),
));

// Roman to Interger
let s = String::from("III");
let result = easy::roman_to_integer::roman_to_int(s);
println!("result: {}", result);
medium::reorder_list::reorder_list(&mut head);

// Longest Common Prefix
let strs = vec![String::from("flower"), String::from("flow"), String::from("flight")];
let result = easy::longest_common_prefix::longest_common_prefix(strs);
println!("result: {}", result);

// Print elements of the list
let mut curr = head;
while let Some(node) = curr {
println!("{}", node.val);
curr = node.next;
}
}

0 comments on commit d4ceff1

Please sign in to comment.