Update 0300.最长上升子序列.md

最新力扣新增测试案例
nums = [0] 预期输出 1 实际输出 0
就是nums.length == 0 时 要return 1
This commit is contained in:
LePing Huang
2023-12-05 16:52:40 +08:00
committed by GitHub
parent f47dd60148
commit a18bca3625

View File

@ -130,7 +130,7 @@ public:
class Solution { class Solution {
public int lengthOfLIS(int[] nums) { public int lengthOfLIS(int[] nums) {
int[] dp = new int[nums.length]; int[] dp = new int[nums.length];
int res = 0; int res = 1;
Arrays.fill(dp, 1); Arrays.fill(dp, 1);
for (int i = 1; i < dp.length; i++) { for (int i = 1; i < dp.length; i++) {
for (int j = 0; j < i; j++) { for (int j = 0; j < i; j++) {