PROBLEM LINK:
ALUN2021-INCSEQ
DIFFICULTY:
Simple
PREREQUISITES:
Basics
EXPLANATION:
Create another array A of the same size as that of input array V. Array A will store the maximum length of increasing sub-array upto the index(including the index). Fill every index of A with value 1 because every element is an increasing sub-array. Now we will traverse through input array and check the following condition:
V[i] > V[i-1]
- If the condition is true we will update array A as:
A[i] = A[i-1]+1
- Else
continue
Maximum value present in array A is the final answer to the problem.
TIME COMPLEXITY:
It takes linear time to traverse through the array so:
O(n)
SOLUTION
Here is my whole solution code.