Author: Ayush Nagal
Given the value of d, we have to perform d left shift operations on the given array. One left shift operation shifts the elements by one unit to the left in a circular fashion.
Instead of shifting the elements one by one, we first print elements from index d to index n-1. Then from 0 to index d-1.
for(int i=d;i < n;i++) cout<< a[i]<< " "; for(int i = 0;i < d;i++) cout<< a[i]<< " ";
Author’s solution can be found here.