0% found this document useful (0 votes)
9 views2 pages

Left Rotation of Circular Array

The document describes a left rotation operation on a circular array, where elements are shifted to the left and those that fall off reappear at the right end. It outlines the function parameters for performing the rotation and provides an example input and output. The input consists of the number of integers and the number of rotations, followed by the array elements.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Left Rotation of Circular Array

The document describes a left rotation operation on a circular array, where elements are shifted to the left and those that fall off reappear at the right end. It outlines the function parameters for performing the rotation and provides an example input and output. The input consists of the number of integers and the number of rotations, followed by the array elements.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Left Rotation

A operation on a circular array shifts each of the array's elements unit to the left. The
elements that fall off the left end reappear at the right end. Given an integer , rotate the array that
many steps to the left and return the result.

Example

After rotations, .

Function Description

Complete the function with the following parameters:

: the amount to rotate by

: the array to rotate

Returns

: the rotated array

Input Format

The first line contains two space-separated integers that denote , the number of integers, and , the
number of left rotations to perform.
The second line contains space-separated integers that describe .

Constraints

Sample Input

STDIN Function
----- --------
5 4 n = 5 d = 4
1 2 3 4 5 arr = [1, 2, 3, 4, 5]

Sample Output

5 1 2 3 4

Explanation

1/2
To perform left rotations, the array undergoes the following sequence of changes:

2/2

You might also like