2364. Count Number of Bad Pairs

Share this post on:

Permutation: in order. n!/(n – m)!

Combination: order not considered. n!/((n – m)! * m!)

Key point of this problem is to transfer i – j = nums[i] – nums[j] into i – nums[i] = j – nums[j].

Share this post on:

Leave a Reply

Your email address will not be published. Required fields are marked *