728x90
https://leetcode.com/problems/number-of-arithmetic-triplets
class Solution:
def arithmeticTriplets(self, nums: List[int], diff: int) -> int:
count = 0
for n in range(2, len(nums)):
i = nums[n] - diff
j = nums[n] - (2 * diff)
if i in nums and j in nums:
count += 1
return count
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 1832. Check if the Sentence Is Pangram (0) | 2024.02.22 |
---|---|
[Leetcode] 2006. Count Number of Pairs With Absolute Difference K (0) | 2024.02.22 |
[Leetcode] 2325. Decode the Message (0) | 2024.02.21 |
[Leetcode] 1630. Arithmetic Subarrays (0) | 2024.02.20 |
[Leetcode] 1656. Design an Ordered Stream (0) | 2024.02.19 |