diff options
Diffstat (limited to 'num_bad_pairs.rs')
-rw-r--r-- | num_bad_pairs.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/num_bad_pairs.rs b/num_bad_pairs.rs index 8e1e7dd..88119d8 100644 --- a/num_bad_pairs.rs +++ b/num_bad_pairs.rs @@ -1,10 +1,11 @@ +// 2364. Count Number of Bad Pairs use std::collections::HashMap; struct Solution; /* - * given: 0-indexed integer array - * bad pair: (i, j) if - * i < j && j - i != nums[j] - nums[i] + * you are given a 0-indexed integer array 'nums'. a pair of indices '(i, j)' is + * a bad pair if 'i < j' and 'j - i != nums[j] - nums[i]'. return the total + * number of bad pairs in 'nums'. */ impl Solution { @@ -22,8 +23,8 @@ impl Solution { } fn main() { - let nums1 = vec![4,1,3,3]; - let nums2 = vec![1,2,3,4,5]; - println!("{}", Solution::count_bad_pairs(nums1)); //expect: 5 - println!("{}", Solution::count_bad_pairs(nums2)); //expect: 0 + let n1 = vec![4, 1, 3, 3]; + let n2 = vec![1, 2, 3, 4, 5]; + println!("{}", Solution::count_bad_pairs(n1)); //expect: 5 + println!("{}", Solution::count_bad_pairs(n2)); //expect: 0 } |