LeetCode 算法题解与代码实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Solution {
public int lengthOfLIS(int[] nums) {
int ans = 1;
int[] f = new int[nums.length];
Arrays.fill(f, 1);
for (int i = 1; i < nums.length; i++) {
for (int j = 0; j < i; j++) {
if (nums[i] > nums[j]) {
f[i] = Math.max(f[i], f[j]+1);
}
}
ans = Math.max(ans, f[i]);
}
return ans;
}
}

Comments
Recent Posts
Untitled
Categories
Tags
Website Info
Article Count :
2
Total Word Count :
1.6k
Unique Visitors :
Page Views :
Last Update :