Complete the code to initialize the dp array with 1s for each element.
dp = [[1]] * len(nums)
Each element starts with a subsequence length of 1 (the element itself).
Complete the code to check if the current element can extend the subsequence ending at j.
if nums[i] [1] nums[j]:
We want to extend the subsequence only if current element is greater than previous.
Fix the error in updating dp[i] to the maximum subsequence length.
dp[i] = max(dp[i], dp[[1]] + 1)
We compare dp[i] with dp[j] + 1 because we extend the subsequence ending at j.
Fill both blanks to complete the nested loops for LIS calculation.
for [1] in range(1, len(nums)): for [2] in range([1]):
Outer loop uses i from 1 to end, inner loop uses j from 0 to i-1 to compare elements.
Fill both blanks to return the length of the longest increasing subsequence.
return max(dp) if nums [1] [] else [2]
Return max(dp) if nums is not empty, else return 0 for empty input.
