Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Bad Pairs

Count Number of Bad Pairs asks you to examine an integer array and return how many index pairs are bad, meaning their index gap differs from the corresponding value difference.

Statement

Given a 00 indexed integer array nums, a pair of indices (i, j) is considered a bad pair if i<ji < j and j−i≠j - i \neq nums[j] −- nums[i].

Return the total number of bad pairs in nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Bad Pairs

Count Number of Bad Pairs asks you to examine an integer array and return how many index pairs are bad, meaning their index gap differs from the corresponding value difference.

Statement

Given a 00 indexed integer array nums, a pair of indices (i, j) is considered a bad pair if i<ji < j and j−i≠j - i \neq nums[j] −- nums[i].

Return the total number of bad pairs in nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9