You are viewing a single comment's thread. Return to all comments →
C++ Solution:
vector rotateLeft(int d, vector arr) {
auto calcOldIndex = [](int newIndex, int shift, int size) { int tmp = newIndex + shift; if(tmp >= size) tmp = tmp - size; return tmp; }; vector<int> res; for(int i = 0; i < (int)arr.size(); i++){ res.push_back(arr[calcOldIndex(i, d, arr.size())]); } return res;
}
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 →
C++ Solution:
vector rotateLeft(int d, vector arr) {
}