← ALL NOTES
Array

2364. Count Number of Bad Pairs

A pair of indices (i, j) with i < j is bad if j − i ≠ nums[j] − nums[i]. Count the bad pairs. There are C(n,2) pairs total; it's easier to count the good pairs and subtract.

Loading…