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