Back to course home
0% completed
Solution: Continuous Subarrays
Problem Statement
You are given a 0-indexed array of integers called nums
. A subarray of num
is called continuous if the following condition is met:
- consider i, i + 1, ..., j be the indices in the subarray. Then, for each pair of indices i <= i1, i2 <= j, 0 <= |nums[i1] - nums[i2]| <= 2.
Return the total number of continuous subarrays within nums
.
A subarray is defined as any contiguous, non-empty sequence of elements within an array.
Examples
Example 1:
- Input: nums =
[1, 2, 2, 13, 1]
- Expected Output:
8
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible