Menu
Question Index
...

Write a program to rotate elements of given array to left by K positions.

Input (int[], int) Output (int[])
{1, 2, 3, 4, 5, 6, 7, 8}, 2 {3, 4, 5, 6, 7, 8, 1, 2}
{1, 2, 3, 4, 5, 6, 7, 8}, 5 {6, 7, 8, 1, 2, 3, 4, 5}
{20, 6, 8, 11, 30}, 3 {11, 30, 20, 6, 8}
{12, 15, 19, 1, 33}, 1 {15, 19, 1, 33, 12}
{5, 6, 7, 8, 9, 10}, -2 {5, 6, 7, 8, 9, 10}
{4, 6, 5, 7, 1}, 11 {6, 5, 7, 1, 4}



class RotateArrayElementsLeftByKPositions
{
    public static void main(String s[])
    {
        int inputArray[] = {3, 4, 5, 6, 7, 8};
        int k = 5;
        rotateLeft(inputArray, k);
        System.out.println("After rotating array to left by " + k + " postions we get");
        for (int element : inputArray)
        System.out.print(element + " ");

    }


    public static void rotateLeft(int inputArray[], int k) {
    }

}

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App