Skip to content

Instantly share code, notes, and snippets.

View ArthurBook's full-sized avatar
💭
Enjoying efficient markets

Arthur Böök ArthurBook

💭
Enjoying efficient markets
  • San Francisco
View GitHub Profile
@lovasoa
lovasoa / longest-increasing-subsequence.py
Last active October 1, 2020 19:58
Solution to the longest increasing subsequence problem, in 5 lines of python
def lis(a):
L = []
for (k,v) in enumerate(a):
L.append(max([L[i] for (i,n) in enumerate(a[:k]) if n<v] or [[]], key=len) + [v])
return max(L, key=len)
inp = [int(a) for a in input("List of integers: ").split(' ')]
print(lis(inp));