Jump to content

Longest increasing subsequence: Difference between revisions

→‎Python: Patience sorting method: use python slice technique (x[i:i+k] = [...]) to simplify if-else case for replace/append new node
(→‎{{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:
for di in d:
j = bisect_left(pileTops, Node(di, None))
new_nodepileTops[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]
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.