Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加 Java 版本 #128

Merged
merged 13 commits into from
May 15, 2021
Prev Previous commit
Next Next commit
Update 0300.最长上升子序列.md
  • Loading branch information
zhenzi committed May 15, 2021
commit 335c4adcdfdf7e5d2a20c2a42bd0070b1356a24a
21 changes: 20 additions & 1 deletion problems/0300.最长上升子序列.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,26 @@ public:


Java:

```Java
class Solution {
public int lengthOfLIS(int[] nums) {
int[] dp = new int[nums.length];
Arrays.fill(dp, 1);
for (int i = 0; i < dp.length; i++) {
for (int j = 0; j < i; j++) {
if (nums[i] > nums[j]) {
dp[i] = Math.max(dp[i], dp[j] + 1);
}
}
}
int res = 0;
for (int i = 0; i < dp.length; i++) {
res = Math.max(res, dp[i]);
}
return res;
}
}
```

Python:

Expand Down