Skip to content

Commit 07e2aef

Browse files
committed
smallest_missing_multiple_of_k.rs
1 parent 44783a7 commit 07e2aef

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use std::collections::HashSet;
2+
3+
impl Solution {
4+
pub fn missing_multiple(nums: Vec<i32>, k: i32) -> i32 {
5+
let st = nums.into_iter().collect::<HashSet<i32>>();
6+
let mut i = 1;
7+
loop {
8+
if !st.contains(&(k * i)) {
9+
return k * i;
10+
}
11+
i += 1;
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)