• + 0 comments

    I liked your approach.But I would like to pin point one thing here as you have been already given an array and N number of rotation.ON that array you have to perform operations.You are changing it while reading from console. please have a look at this and let me know if this can be optimized.

    static int[] leftRotation(int[] a, int d) { // Complete this function

            int[] b= new int[a.length];
            for(int iLoop=0;iLoop<a.length;iLoop++){
                b[iLoop]=a[iLoop];
            }
            for(int iLoop=0;iLoop<a.length;iLoop++){
               a[iLoop]=b[(iLoop+d)%a.length]; 
            }
        return a;
    }
    
    
    But Really good solution though.