Skip to content

Commit 82f5a05

Browse files
committed
Added solution of problem 153
1 parent b0cf87c commit 82f5a05

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/solutions/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub mod s0148_sort_list;
8888
pub mod s0150_evaluate_reverse_polish_notation;
8989
pub mod s0151_reverse_words_in_a_string;
9090
pub mod s0152_maximum_product_subarray;
91+
pub mod s0153_find_minimum_in_rotated_sorted_array;
9192
pub mod s0231_power_of_two;
9293
pub mod s0232_implement_queue_using_stacks;
9394
pub mod s0234_palindrome_linked_list;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pub fn find_min(nums: Vec<i32>) -> i32 {
2+
*nums.iter().min().unwrap()
3+
}
4+
5+
#[cfg(test)]
6+
mod test {
7+
use super::*;
8+
9+
#[test]
10+
fn test_case_1() {
11+
assert_eq!(find_min(vec![3, 4, 5, 1, 2]), 1);
12+
}
13+
14+
#[test]
15+
fn test_case_2() {
16+
assert_eq!(find_min(vec![4, 5, 6, 7, 0, 1, 2]), 0);
17+
}
18+
19+
#[test]
20+
fn test_case_3() {
21+
assert_eq!(find_min(vec![11, 13, 15, 17]), 11);
22+
}
23+
}

0 commit comments

Comments
 (0)