Question DSA-DP-0010
MediumWhat is the output of this code?
a = [10, 9, 2, 5, 3, 7, 101, 18]
dp = [1] * len(a)
for i in range(len(a)):
for j in range(i):
if a[j] < a[i]:
dp[i] = max(dp[i], dp[j] + 1)
print(max(dp))
- A.
2
- B.
3
- C.
Sign up free to see the answer and a step-by-step explanation.