close
Given an array of integers nums.
A pair (i,j) is called good if nums[i] == nums[j] and i < j.
Return the number of good pairs.
暴力破解:
class Solution: def numIdenticalPairs(self, nums: List[int]) -> int: count=0 for x in range(len(nums)): for y in range(x+1,len(nums)): if nums[x]==nums[y]: count+=1 return count
文章標籤
全站熱搜
留言列表