#3718
Easy Algorithms Smallest missing multiple of k
Array Hash Table
63.1% acceptance
Feb 24, 2026
54
3
Given an integer array nums and an integer k, return the smallest positive multiple of k that is missing from nums.
A multiple of k is any positive integer divisible by k.
Solution
Rust
Time O(n)
Space O(1)
impl Solution {
pub fn missing_multiple(nums: Vec<i32>, k: i32) -> i32 {
let set: std::collections::HashSet<i32> = nums.into_iter().collect();
let mut m = k;
while set.contains(&m) {
m += k;
}
m
}
}