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 |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 125. Valid Palindrome (0) | 2022.03.15 |
---|---|
leetcode 2108. Find First Palindromic String in the Array (0) | 2022.03.15 |
leetcode 1844. Replace All Digits with Characters (0) | 2022.03.15 |
leetcode 2089. Find Target Indices After Sorting Array (0) | 2022.03.15 |
직사각형 별찍기 (0) | 2022.03.15 |
댓글