• + 0 comments

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
    
        int n = in.nextInt();  // number of elements
        int d = in.nextInt();  // number of left rotations
    
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
    
        // Perform left rotations efficiently
        int[] rotated = new int[n];
        for (int i = 0; i < n; i++) {
            rotated[i] = arr[(i + d) % n];
        }
    
        // Print result
        for (int i = 0; i < n; i++) {
            System.out.print(rotated[i] + (i < n - 1 ? " " : ""));
        }
    
        in.close();
    }
    

    }