Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Left Rotation #40

Open
ndrohith09 opened this issue Oct 19, 2022 · 5 comments
Open

Left Rotation #40

ndrohith09 opened this issue Oct 19, 2022 · 5 comments
Assignees
Labels
easy question Further information is requested

Comments

@ndrohith09
Copy link
Member

A left rotation operation on an array of size shifts each of the array's elements 1 unit to the left. Given an integer, d , rotate the array that many steps left and return the result.

Example

d = 2 
arr = [1,2,3,5] 
After 2 rotations, arr' = [3,4,5,1,2] 

Function Description

Complete the rotateLeft function in the editor below.
rotateLeft has the following parameters:

  • int d: the amount to rotate by
  • int arr[n]: the array to rotate

Returns

  • int[n]: the rotated array

Input Format

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

Constraints

image

Sample Input

5 4
1 2 3 4 5

Sample Output

5 1 2 3 4

Explanation

To perform left rotations, the array undergoes the following sequence of changes:
image

@ndrohith09 ndrohith09 added question Further information is requested easy labels Oct 19, 2022
@theNamanchauhan
Copy link
Contributor

I want to contribute using python

theNamanchauhan added a commit to theNamanchauhan/hacktoberfest that referenced this issue Oct 19, 2022
@skandhavs
Copy link
Contributor

Hi I would like to do this in C++. Can you please assign it to me ??

@krithi113
Copy link
Contributor

I would like to solve this in Java

@Tr1ck-5t3r
Copy link
Contributor

i would like to solve this in c

This was referenced Oct 19, 2022
@likhi-23
Copy link
Contributor

i would like to solve this in c++ . can you please assign me this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
easy question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants