We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Data Structures
- Arrays
- Left Rotation
- Discussions
Left Rotation
Left Rotation
Sort by
recency
|
3542 Discussions
|
Please Login in order to post a comment
vector rotateLeft(int d, vector arr) { int n = arr.size(); if(d>n){ d = d%n; } reverse(arr.begin(),arr.begin()+d); reverse(arr.begin()+d,arr.end()); reverse(arr.begin(),arr.end()); return arr; }
Java Solution
my python sollution
My solution in Python 3:
My solution in Python: