/
rnekrasov
/
Python
Обзор
Документация
Войти
/
rnekrasov
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
longest_increasing_subsequence_length.py
23 строки
564 B
slowy07
refactor: clean code
30 янв 2022, 04:33
30 янв 2022, 04:33
f0af0c4
Код
Авторство
О чём код?
""" Author- DIWAKAR JAISWAL find lenth Longest increasing subsequence of given array. """ def lis(a): n = len(a) # initialize ans array same lenth as 1 ans = [1] * n for i in range(1, n): # now compare with first index to that index for j in range(i): if a[i] > a[j] and ans[i] < ans[j] + 1: ans[i] = ans[j] + 1 return max(ans) a = [1, 3, 2, 6, 4] # longest increasing subsequence=[{1<3<6},{1<3<4},{1<2<6},{1<2<4}] length is 3 print("Maximum Length of longest increasing subsequence ", lis(a))