You are viewing a single comment's thread. Return to all comments →
O(1) time vector rotateLeft(int d, vector arr) { vector result; int step = d % arr.size();
vector<int> left(arr.begin() + step, arr.end()); vector<int> right(arr.begin(), arr.begin() + step); result.insert(result.end(), left.begin(), left.end()); result.insert(result.end(), right.begin(), right.end()); return result;
}
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Left Rotation
You are viewing a single comment's thread. Return to all comments →
O(1) time vector rotateLeft(int d, vector arr) { vector result; int step = d % arr.size();
}