cKK

............当你觉得自己很辛苦,说明你正在走上坡路.............坚持做自己懒得做但是正确的事情,你就能得到别人想得到却得不到的东西............

导航

Longest Increasing Subsequence(DP)

Posted on 2016-03-26 22:18  cKK  阅读(163)  评论(0编辑  收藏  举报
public static int LIS(List<Integer> al) {
		int[] arr = new int[al.size()];
		int lis = 0;
		arr[0] = 1;
		for (int i = 1; i < al.size(); i++) {
			if (al.get(i) > al.get(i - 1))
				arr[i] = arr[i - 1] + 1;
			else 
				arr[i] = 1;
		}
		for (int i : arr) {
			if (arr[i] > lis)
				lis = arr[i];
		}
		return lis;
	}