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

anonymous


1 array = [1, 2, 3] 2 reversed = array[::-1] # [3, 2, 1]

Linkerin