n = 5a = [1,4,3,5,2]f = [0] * nf[0] = 1for i in range(1,n): print(f) m = 0 for j in range(i): if a[j] < a[i]: if f[j] > m: m = f[j] f[i] = m + 1print(max(f))
45
[1, 0, 0, 0, 0] [1, 2, 0, 0, 0] [1, 2, 2, 0, 0] [1, 2, 2, 3, 0] 3
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!