diff options
Diffstat (limited to 'progs/a423.py')
-rw-r--r-- | progs/a423.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/progs/a423.py b/progs/a423.py new file mode 100644 index 0000000..4bd6530 --- /dev/null +++ b/progs/a423.py @@ -0,0 +1,13 @@ +def max_len_sub( arr, n):
+ mls=[]
+ max = 0
+ for i in range(n):
+ mls.append(1)
+ for i in range(n):
+ for j in range(i):
+ if (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1):
+ mls[i] = mls[j] + 1
+ for i in range(n):
+ if (max < mls[i]):
+ max = mls[i]
+ return max
\ No newline at end of file |