JuniorArray
Longest Strictly Increasing or Strictly Decreasing Subarray
You are given an array of integers nums. Return the length of the longest subarray of nums which is either strictly increasing or strictly decreasing.
Example 1
Input
nums = [1,4,3,3,2]Output
2The longest strictly increasing or strictly decreasing subarrays have length 2, such as
[1,4], [4,3], or [3,2].Example 2
Input
nums = [3,3,3,3]Output
1All elements are equal, so only single-element subarrays are strictly increasing or strictly decreasing.
Constraints
- 1 <= nums.length <= 50
- 1 <= nums[i] <= 50