Skip to content

Rotate Array by K Positions (In-Place Rotation) #365

@shivanjan25

Description

@shivanjan25

Hey @xthxr !
I would love to work on this proposed issue under Hacktoberfest 2025.

Description
In this program, the user provides an array and a number K.
The goal is to rotate the array elements to the right by K positions, but without using any extra array or temporary variable — the rotation should be done in-place.
This program will need to manipulate the array elements carefully so that each element moves to its new position while preserving the others.
A common approach is to use array reversal logic or cyclic element swapping.

Example Output
Enter number of elements: 6
Enter array elements: 1 2 3 4 5 6
Enter K (number of rotations): 2

Original Array: 1 2 3 4 5 6
Rotated Array (by 2): 5 6 1 2 3 4

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions