Open deadsoul44 opened 5 months ago
Thanks! How does this have O(n) complexity when there is an inner loop?
The last_idx
is decremented at every swap. The outer loop stops when i >= last_idx
. Inspired from: https://stackoverflow.com/questions/69764803/how-to-sort-reorder-a-vec-by-indices
Ah, that makes sense! I’ll test it out, I believe the current implementation is also O(n), but this seems a little more concise.
I guess the following implementation has O(n) complexity. Correct me if I am wrong.
It passes all the tests for
pivot_on_split
. It became hacky to handle edge cases. If you like, feel free to copy, modify, and merge it.Link to the playground.