Skip to content

Commit 0401d79

Browse files
committed
solved: 448. Find All Numbers Disappeared in an Array
Signed-off-by: rajput-hemant <[email protected]>
1 parent d9608ba commit 0401d79

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
impl Solution {
2+
pub fn find_disappeared_numbers(nums: Vec<i32>) -> Vec<i32> {
3+
let mut res = Vec::new();
4+
let mut map = std::collections::HashMap::new();
5+
6+
for i in 0..nums.len() {
7+
map.insert(nums[i], i);
8+
}
9+
10+
for i in 1..=nums.len() {
11+
if !map.contains_key(&(i as i32)) {
12+
res.push(i as i32);
13+
}
14+
}
15+
16+
res
17+
}
18+
}

0 commit comments

Comments
 (0)