C++ program to print the left Rotation of the array
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
The naïve approach to solve this problem is to shift the all elements d times but this is a time-consuming process.
We can use a small trick here to print the elements of the array after left rotating d elements.
Let, i = ith iteration D = number of elements to rotate N = size of array Then to left rotate array we can use - arr[i] = arr[(i+D)%N]
C++ Implementation:
Output