diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/num_bad_pairs.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/num_bad_pairs.cpp')
-rw-r--r-- | other/num_bad_pairs.cpp | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/other/num_bad_pairs.cpp b/other/num_bad_pairs.cpp deleted file mode 100644 index 144e6ef..0000000 --- a/other/num_bad_pairs.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// 2364. Count Number of Bad Pairs -#include "leetcode.h" - -/* - * 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'. - */ - -class Solution { -public: - long long countBadPairs(vector<int> &nums) { - long long ans = 0; - unordered_map<int, int> mp; - for (int i = 0; i < nums.size(); ++i) { - ans += i - mp[nums[i] - i]; - mp[nums[i] - i]++; - } - return ans; - } -}; - -int main() { - Solution obj; - vector<int> n1 = {4, 1, 3, 3}, n2 = {1, 2, 3, 4, 5}; - printf("%lld\n", obj.countBadPairs(n1)); // expect: 5 - printf("%lld\n", obj.countBadPairs(n2)); // expect: 0 -} |