We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
you are doing the loop thing wrong. Firstly i should be initialized to n-1 , then it should be i>0 . Now a[i+1]=a[i]; is wrong. It should be a[i]=a[i-1] because you are running loop from end and not from starting.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →
you are doing the loop thing wrong. Firstly i should be initialized to n-1 , then it should be i>0 . Now a[i+1]=a[i]; is wrong. It should be a[i]=a[i-1] because you are running loop from end and not from starting.