3105. Longest Strictly Increasing or Strictly Decreasing Subarray
3105. Longest Strictly Increasing or Strictly Decreasing Subarray
Description
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:
1 | Input: nums = [1,4,3,3,2] |
Example 2:
1 | Input: nums = [3,3,3,3] |
Example 3:
1 | Input: nums = [3,2,1] |
Constraints:
1 <= nums.length <= 50
1 <= nums[i] <= 50
Hints/Notes
- iterate the array twice
Solution
Language: C++
1 | class Solution { |