Cannot understand the description


  • 0
    A

    The example given in the description is confusing
    [1, 2, 3, 4, 5, 6 , 7] rotate 3 steps and it becomes [5, 6, 7, 1, 2, 3, 4].
    It looks like the steps represents the (k + 1) elements that should be put into the back.

    However, here comes the test case [ 1, 2] rotates 1 step and it becomes [ 2, 1]. Now steps represent exact K elements that should be put into the back.

    So how should I understand the question?


  • 4
    C

    [1, 2, 3, 4, 5, 6 , 7]with steps k =3, it is changed like below:
    step 1: [7,1,2,3,4,5,6]
    step 2:[6,7,1,2,3,4,5]
    step 3:[5,6,7,1,2,3,4]
    looks like bits shifting.
    So, as for[1,2] with step = 1;
    it shifts like[2,1]


  • 0
    A

    But it seems like the test cases are expecting result = [1, 2] when nums=[1,2] and k=1.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.