Given an array of integers sorted in ascending order and a positive inte
ger ‘n’, return an array where in the elements are shifted to the righ
t by ‘n’ positions. Ensure, you perform the rotation in place without
the use of a new array.
STL reverse()
reverse(A, 0, n,);
reverse(A, n+1, A.size()- 1))
reverse(A, 0, A.size() - 1);
space complexity O(1)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment