Tap here to switch tabs
Problem
Submissions

Problem: Continuous Subarrays

Try to solve the Continuous Subarrays problem.

Statement

You are given an array of integers nums.

A subarray of nums is called continuous if, for any two elements at indices i and j in the subarray, ∣|nums[i] - nums[j]∣≤2| \leq 2.

Return the total number of continuous subarrays in nums.

Note: A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Continuous Subarrays

Try to solve the Continuous Subarrays problem.

Statement

You are given an array of integers nums.

A subarray of nums is called continuous if, for any two elements at indices i and j in the subarray, ∣|nums[i] - nums[j]∣≤2| \leq 2.

Return the total number of continuous subarrays in nums.

Note: A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9