Arithmetic slices counter
1 def count_arithmetic_slices(nums: list[int]) -> int:
2 n = len(nums)
3 dp = [0] * n
4
5 for i in range(2, n):
6 if nums[i] - nums[i-1] == nums[i-1] - nums[i-2]:
7 dp[i] = dp[i - 1] + 1
8
9 return sum(dp)
10