Longest increasing subsequence: Difference between revisions
Content added Content deleted
(→{{header|Rust}}: I've reverted the Rust code back to the original submission by Donkey-hotei (though it now takes a slice arg rather than a Vec). The version which had been current gave the wrong answers!) |
(→Python: Patience sorting method: use python slice technique (x[i:i+k] = [...]) to simplify if-else case for replace/append new node) |
||
Line 2,067: | Line 2,067: | ||
for di in d: |
for di in d: |
||
j = bisect_left(pileTops, Node(di, None)) |
j = bisect_left(pileTops, Node(di, None)) |
||
pileTops[j:j+1] = [Node(di, pileTops[j-1] if j > 0 else None)] |
|||
if j == len(pileTops): |
|||
pileTops.append(new_node) |
|||
else: |
|||
pileTops[j] = new_node |
|||
return list(pileTops[-1])[::-1] |
return list(pileTops[-1])[::-1] |
||