Count Number of Bad Pairs
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.
Example 1
Input
nums = [4,1,3,3]Output
5There are a total of 5 bad pairs: (0, 1), (0, 2), (0, 3), (1, 2), and (2, 3).
Example 2
Input
nums = [1,2,3,4,5]Output
0There are no bad pairs.
Constraints
- 1 <= nums.length <= 10^5
- 1 <= nums[i] <= 10^9