less than 1 minute read

Given a list of integers nums, return the number of contiguous arithmetic sequences of length ≥ 3.

Constraints

  • n ≤ 10,000 where n is length of nums.

https://binarysearch.com/problems/Arithmetic-Sequences

Examples

Example 1

Input

  • nums = [5, 7, 9, 11, 12, 13]

Output

  • answer = 4

Explanation

We have the following arithmetic sequences:

  • [5, 7, 9]
  • [7, 9, 11]
  • [5, 7, 9, 11]
  • [11, 12, 13]

Solution

Leave a comment