300.Longest Increasing Subsequence Posted on 2017-09-13 | In LeetCode Test cases1234567[10,9,2,5,3,7,101,18][2,5,3,4][2,5,3,4,6][2,3,4,5][5,4,3,2][0][1,1,1,1] Solution 1:123456789101112131415161718192021222324public class Solution { public int lengthOfLIS(int[] nums) { int len = nums.length; if (len < 2) return len; HashMap<Integer, Integer> map = new HashMap<>(); for(int i = 0; i < len; i++) { map.put(i, 1); } int max = 1; for (int i = 1; i < len; i++) { for (int j = 0; j < len; j++) { if (nums[j] < nums[i]) { int bigger = map.get(i) > map.get(j) + 1 ? map.get(i) : map.get(j) + 1; map.put(i, bigger); } } max = max > map.get(i)? max : map.get(i); } return max; }}