You are viewing a single comment's thread. Return to all comments →
I saw this problem in Steven Skiena's book, The Algorithm Design Manual. Below is my solution in C++:
vector<int> rotateLeft(int d, vector<int> arr) { int n = arr.size(); vector<int> a(n); for(int i=0; i<n; i++) { a[i] = arr[(i+d)%n]; } return a; }
Seems like cookies are disabled on this browser, please enable them to open this website
Left Rotation
You are viewing a single comment's thread. Return to all comments →
I saw this problem in Steven Skiena's book, The Algorithm Design Manual. Below is my solution in C++: