2367. Number of Arithmetic Triplets

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2367

class Solution:
    def arithmeticTriplets(self, nums: List[int], diff: int) -> int:
        vis = set(nums)
        return sum(x + diff in vis and x + diff * 2 in vis for x in nums)