Recover RSA
Obviously we can only achieve O(n) for this questions (since we need to move every element). But how can we do O(1) space?
You find the rotating pivot and do 3 reverse actions.
Find rotating index
reverse(A[0...index])
reverse(A[index+1...A.length-1])
reverse(A[0...A.length-1])
Similar to a question in programming pearls.
Last updated