You are viewing a single comment's thread. Return to all comments →
Indeed, its not in-place at all. Also its slow. If you are interested, here's an inplace c++ solution
void rotLeft(vector<int> &a, int d) { int c=a[d],ci=0,n=a.size(); a[d]=0; for(int i=n-1;i>=0;i--){ swap(a[ci],c); if(!c&&i) ci+=n-i+++i; ci=(n+ci-d)%n; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Arrays: Left Rotation
You are viewing a single comment's thread. Return to all comments →
Indeed, its not in-place at all. Also its slow. If you are interested, here's an inplace c++ solution