# Mathematical Computation Problem | Progressive Sequence | Codewindow.in

#### Solution: In C

``````#include <stdio.h>

int main()
{
int previous_len=0,n,a, start=0, c, len=0;
scanf("%d",&n);
for(int i=0; i<n;i++)
scanf("%d",&a[i]);
for (int i=0; i<n-1; i++) {
if(a[i+1] > a[i]) {
len++;
if (len > previous_len) {
previous_len=len;
start=i-len;
}
} else {
previous_len=len;
len=0;
}
}
for(int i = 0; i <= previous_len+1; ++i) {
c[i]=a[start+i];
printf("%d ",c[i]);
}
return 0;
}``````

#### Solution: In Java

``````import java.util.ArrayList;
import java.util.Scanner;

class LongestProgressiveSequence {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
ArrayList<Integer> ls = new ArrayList<Integer>();
Integer[] temp = new Integer;
for (int i = 0; i < t; i++) {
int num = sc.nextInt();
if (!(ls.isEmpty())) {
if (num >=ls.get(ls.size()-1 )) {
} else {
if(ls.size()>temp.length)
temp=ls.toArray(temp);
ls.clear();
}
} else {
}
}
if(ls.size()>temp.length)
{
temp=ls.toArray(temp);
ls.clear();
}
for (int i = 0; i < temp.length; i++) {
if(i<temp.length-1)
System.out.print(temp[i]+" ");
else
System.out.println(temp[i]);
}
}
}``````

#### Solution: In Python 3

``````class Solution(object):
def lengthOfLIS(self, nums):
tails =[0 for i in range(len(nums))]
size = len(nums)
for x in nums:
i=0
j=size
while i!=j:
mid = i + (j-i)//2
if tails[mid]< x:
i= mid+1
else:
j = mid
tails[i] = x
size = max(i+1,size)
return tails

ob1 = Solution()
n = int(input())
num = list(map(int, input().split(' ')))
print(ob1.lengthOfLIS(num))``````