Leetcode 1512 Number of Good Pairs
2022-02-06 14:28 作者:您是打尖兒還是住店呢 | 我要投稿
Given an array of integers?nums
, return?the number of?good pairs.
A pair?(i, j)
?is called?good?if?nums[i] == nums[j]
?and?i
?<?j
.
?
Example 1:
Input: nums = [1,2,3,1,1,3]Output: 4Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
Example 2:
Input: nums = [1,1,1,1]Output: 6Explanation: Each pair in the array are good.
Runtime:?1 ms, faster than?81.21%?of?Java?online submissions for?Number of Good Pairs.
Memory Usage:?39.7 MB, less than?14.56%?of?Java?online submissions for?Number of Good Pairs.
整體表現(xiàn)不太好。只能說一般。
標(biāo)簽: