usr bin env python3 -1 -2 dp len for in range len for in range if and

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/usr/bin/env python3
a = [3, -1, 3, -2, 0, 5, 7, 2, 5, 2]
dp = [1] * len(a)
for i in range(len(a)):
for j in range(i):
if a[j] < a[i] and dp[i] < dp[j] + 1:
dp[i] = dp[j] + 1
print(max(dp))