标签:
public class Solution { public int lengthOfLIS(int[] nums) { int length = nums.length; List<Integer> record = new ArrayList<Integer>(); for (int i = length - 1; i >= 0; i--) { int count = 0; if (record.isEmpty()) { record.add(nums[i]); continue; } for (int j = record.size() - 1; j >= 0; j--) { if (nums[i] < record.get(j)) { count = j + 1; break; } } if (record.size() > count) { record.set(count, Math.max(nums[i], record.get(count))); } else { record.add(nums[i]); } } return record.size(); } }
[LeetCode]Longest Increasing Subsequence
标签:
原文地址:http://www.cnblogs.com/vision-love-programming/p/5009146.html