You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can have the video explanation here : https://youtu.be/lyUDSB4Sg7Y
vector<int> rotateLeft(int d, vector<int> arr) { int n = arr.size(); vector<int> result(n); for(int i = 0; i < n; i++){ int newIndex = (i - d + n) % n; result[newIndex] = arr[i]; } return result; }
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 →
Here is my c++ solution, you can have the video explanation here : https://youtu.be/lyUDSB4Sg7Y