본문 바로가기
python-algorithm

Leetcode 1512. Number of Good Pairs

by 무적김두칠 2021. 7. 13.

1
2
3
4
5
6
7
8
class Solution:
    def numIdenticalPairs(self, nums: List[int]) -> int:
        ans=0
        for i in range(len(nums)):
            for j in range(i,len(nums)):
                if nums[i]==nums[j]:
                    if i<j:ans+=1
        return ans
cs
반응형

'python-algorithm' 카테고리의 다른 글

백준 5539 콜센터  (0) 2021.07.15
Leetcode 28. Implement strStr()  (0) 2021.07.13
Leetcode 1470. Shuffle the Array  (0) 2021.07.13
Leetcode 1431. Kids With the Greatest Number of Candies  (0) 2021.07.13
Leetcode 9. Palindrome Number  (0) 2021.07.12

댓글