Previous
0 / 21
Module DEMO-32-106DEMO-C-32

Longest Increasing Subarray

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Find the length of the longest subarray (contiguous elements) where the elements are strictly increasing. Input n and array.

Example

Input:

6 1 2 5 3 4 1

Output:

3

(Subarrays: 1,2,5 length 3. 3,4 length 2. Max is 3)

Constraints

n <= 100

Input Format

n, array

Output Format

Max length

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
6
1 2 5 3 4 1
3
Increasing: 1-2-5.
Sample #2
Public sample
4
1 2 2 3
2
Strictly increasing. 1->2 (len 2). 2->3 (len 2). 2==2 breaks.
Sample #3
Public sample
7
1 3 2 4 5 6 2
4
Subarray 2-4-5-6 has length 4.
Sample #4
Public sample
8
1 1 1 1 1 1 1 1
1
All elements equal, no increasing subarrays longer than 1.
Sample #5
Public sample
6
1 2 1 2 3 4
4
Last four elements 1-2-3-4 form the longest increasing subarray.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings