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
|
3528 Discussions
|
Please Login in order to post a comment
I have got a very short and efficient code for this. I used Python
def rotateLeft(d, arr): # Efficient left rotation using slicing return arr[d:] + arr[:d]
public static void reverse(List arr1) { int left = 0, right = arr1.size() - 1; while (left < right) { int l = arr1.get(left); int r = arr1.get(right); arr1.set(left, r); arr1.set(right, l); left++; right--; } }
def rotateLeft(d, arr): for i in range(d): arr.append(arr.pop(0)) return arr
Hey everyone, I was working through the Left Rotation problem, and I found it to be a great exercise for understanding array manipulation. If you're interested in checking out more tools related to data and statistics, I recently came across a cool website that offers a Name Popularity Checker. It's a handy resource to check how popular a name has been over time. Might be fun to try out if you're interested in names and trends!