Skip to content

Practice Longest Strictly Increasing or Strictly Decreasing Subarray

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3105
LeetCode Problem

Longest Strictly Increasing or Strictly Decreasing Subarray

Problem Statement

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.

Source: Longest Strictly Increasing or Strictly Decreasing Subarray on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,4,3,3,2]
Output
2

# Example 2

Input
nums = [3,3,3,3]
Output
1

# Example 3

Input
nums = [3,2,1]
Output
3

Constraints

1 <= nums.length <= 50
1 <= nums[i] <= 50

Related LeetCode Problems

Practice more problems similar to Longest Strictly Increasing or Strictly Decreasing Subarray.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.