Skip to content
Onsite

Longest Increasing Subarray

EasyP3Coding

Given an array nums, return the length of the longest contiguous subarray in which each element is strictly greater than the one before it. A single element counts as an increasing subarray of length 1. For an empty array return 0.

Example 1

Input
nums = [1,3,5,4,7]
Output
3
Why
The subarray [1,3,5] has length 3.

Example 2

Input
nums = [2,2,2,2]
Output
1
Why
No element is greater than its predecessor, so the best length is 1.

Example 3

Input
nums = []
Output
0

Constraints

  • 0 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9

Hints

Run checks the 3 visible tests, Submit all 10.