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
|
3565 Discussions
|
Please Login in order to post a comment
Simplest solution in Python!
def rotateLeft(d, arr): for i in range(d): num = arr.pop(0) arr.append(num) return arr
Mi solución en Python 3:
JavaScript
def rotateLeft(d, arr): return arr[d:]+arr[:d]
C++: Insert the values into a new array and use modulus operator to wrap around original array when iterating through