How can I set next_permutation on some segment of array using Treap with implicit key in O(log(n)) time...I just need logic not code. Example arr = [1,2,3,5,4] prev_permutation(