https://leetcode.com/problems/number-of-arithmetic-triplets/description/
1
2
3
4
5
6
7
8
9
10
|
class Solution:
def arithmeticTriplets(self, nums: List[int], diff: int) -> int:
answer = 0
for i in range(len(nums)-2):
for j in range(i+1,len(nums)-1):
for k in range(j+1,len(nums)):
if nums[j] - nums[i] == diff and nums[k] - nums[j] == diff:
answer+=1
return answer
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2418. Sort the People (0) | 2023.01.09 |
---|---|
leetcode 2315. Count Asterisks (0) | 2023.01.09 |
백준 10203 Count Vowels (0) | 2023.01.07 |
leetcode 2520. Count the Digits That Divide a Number (0) | 2023.01.06 |
leetcode 2469. Convert the Temperature (0) | 2023.01.06 |
댓글