aboutsummaryrefslogtreecommitdiff
path: root/other/contains_duplicate2.rs
diff options
context:
space:
mode:
Diffstat (limited to 'other/contains_duplicate2.rs')
-rw-r--r--other/contains_duplicate2.rs21
1 files changed, 0 insertions, 21 deletions
diff --git a/other/contains_duplicate2.rs b/other/contains_duplicate2.rs
deleted file mode 100644
index b016e21..0000000
--- a/other/contains_duplicate2.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-use std::collections::HashMap;
-struct Solution;
-
-impl Solution {
- pub fn contains_nearby_duplicate(nums: Vec<i32>, k: i32) -> bool {
- let mut hm = HashMap::new();
- for (i, n) in nums.iter().enumerate() {
- if let Some(j) = hm.insert(n, i) {
- if (i as i32) - (j as i32) <= k {
- return true;
- }
- }
- }
- false
- }
-}
-
-fn main() {
- let nums = vec![1,2,3,1];
- print!("{}", Solution::contains_nearby_duplicate(nums, 3));
-}