[LeetCode] 2364. Count Number of Bad Pairs (Python)
·
알고리즘/LeetCode
난이도: Medium문제 설명You are given a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i 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: 5Explanation: The pair (0, 1) is a bad pair since 1 - 0 != 1 - 4.The pair (0, 2) is a bad pair since 2 - 0 != 3 - 4, 2 != -1.The pair (0, 3) is a bad pair since 3 - 0 !..