
Untitled
By: a guest on
Aug 3rd, 2012 | syntax:
Java | size: 1.17 KB | hits: 20 | expires: Never
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package coding;
import com.sun.corba.se.impl.encoding.BufferManagerFactory;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
*
* @author Mohamed
*/
public class Coding {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
int a[]={1 ,4 ,2 ,4 ,3};
System.out.println( LIS(a));
}
public static int LIS(int[] a) {
int n = a.length;
int max;
int[] q = new int[n];
for (int k = 0; k < n; k++) {
max = 0;
for (int j = 0; j < k; j++) {
if (a[k] > a[j]) {
if (q[j] > max) {
max = q[j];
}
}
}
q[k] = max + 1;
}
max = 0;
for (int i = 0; i < n; i++) {
if (q[i] > max) {
max = q[i];
}
}
return max;
}
}