classSolution: defarithmeticTriplets(self, nums: List[int], diff: int) -> int: map = {} res = 0 n = len(nums) i = 0 j = 1 k = 2 for i inrange(0, n): j = max(i+1, j) while j < n and nums[j] < nums[i] + diff: j +=1 if j < n and nums[j] == nums[i]+ diff: k = max(j+1, k) while k < n and nums[k] < nums[j]+ diff: k += 1 if k < n and nums[k] == nums[j]+ diff: res +=1 if j >= n or k >=n: break