본문 바로가기
python-algorithm

leetcode 2176. Count Equal and Divisible Pairs in an Array

by 무적김두칠 2022. 3. 15.

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

댓글