algo/ds puzzles
Pages
Home
trees and trees alone :D
Sunday, August 28, 2011
rotating array
problem: Rotate the array a[n] in kth place like this
1 2 3 4 5 6 n= 6 k =3 4 5 6 1 2 3
sol:
1. revert first [0, k] subarray
2. revert last [k+1, n] subarray
3. revert whole of array
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment