import java.util.*;
class Ideone{
public static void main
(String[] args
){ int[] a = { 10, 22, 9, 33, 21, 50, 41, 60, 80 }; //max increasing subsequence length of this sequence is 6
int[] longIncSeq = new int[a.length];
//Every element is part of its longest increasing subsequence
for(int i=0; i<a.length; i++)
longIncSeq[i] = 1;
//Now check longest increasing sequence for every sequence end with ith position of args
for(int i=0; i<a.length; i++){
for(int j=0; j<i; j++){
if(a[i] > a[j] && longIncSeq[i] < longIncSeq[j]+ 1){
longIncSeq[i] = longIncSeq[j]+1;
}
}
}
//Find the max value and print it
int maxSeqLength = 0 ;
for(int i=0; i < longIncSeq.length; i++){
maxSeqLength = maxSeqLength > longIncSeq[i] ? maxSeqLength : longIncSeq[i];
}
System.
out.
println("Longest increasing subsequene length => "+ maxSeqLength
); }
}