Skip to content
CampusEduX

Rotate an Array by K Positions

Mediumjavapythonccppjavascript

Given an array of N integers and an integer K, rotate the array to the right by K positions.

Input Format

The first line contains two integers N and K. The second line contains N space-separated integers.

Output Format

Print the rotated array as N space-separated integers on one line.

Related Problems

  • Find the Majority Element
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Maximum Subarray Sum
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Find a Subarray with Given Sum
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...