public int LIS (int[] arr) { // write code here if (arr.length == 0) return 0; int[] dp = new int[arr.length]; Arrays.fill(dp, 1); int res = 1; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < i; j++) { if (arr[i] > arr[j]) { dp[i] = Math.max (dp[i], dp[j] + 1); res = Math.max(res, dp[i]); } } } return res; }
点赞

相关推荐

牛客网
牛客企业服务