mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-06-19 12:24:11 -04:00
...
This commit is contained in:
parent
bc442a0727
commit
c3cb3f1c1b
2 changed files with 34 additions and 25 deletions
src/builtin_structures
|
@ -11,20 +11,22 @@ def find_long_con_inc(seq):
|
|||
[-2, 3, 5]
|
||||
>>> find_long_con_inc([1, 3, -2, 3, 5, 6])
|
||||
[-2, 3, 5, 6]
|
||||
>>> find_long_con_inc([1, 3, 4, -13, 2, 5, 8, -1, 2,-17])
|
||||
[-13, 2, 5, 8]
|
||||
'''
|
||||
|
||||
aux = []
|
||||
result = []
|
||||
res, aux = [], []
|
||||
seq.append(-float('infinity'))
|
||||
|
||||
for i, pivot in enumerate(seq[:-1]):
|
||||
aux.append(pivot)
|
||||
if pivot > seq[i+1]:
|
||||
if len(aux) > len(result):
|
||||
result = aux
|
||||
for i, n in enumerate(seq[:-1]):
|
||||
aux.append(n)
|
||||
if n > seq[i+1]:
|
||||
if len(res) < len(aux):
|
||||
res = aux[:]
|
||||
aux = []
|
||||
|
||||
return result
|
||||
return res
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue