LEFROT - Editorial

PROBLEM LINK:

Practice
Contest

Author: Ayush Nagal

DIFFICULTY:

SIMPLE

PREREQUISITES:

Array

PROBLEM:

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.

EXPLANATION:

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 SOLUTIONS:

Author’s solution can be found here.