You are viewing a single comment's thread. Return to all comments →
using namespace std;
int main() { int n, d; cin >> n >> d; vector a(n); for (int i = 0; i < n; i++) cin >> a[i];
d %= n; vector<int> res(n); for (int i = 0; i < n; i++) res[i] = a[(i + d) % n]; for (int i = 0; i < n; i++) cout << res[i] << (i == n - 1 ? '\n' : ' '); return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Left Rotation
You are viewing a single comment's thread. Return to all comments →
include
using namespace std;
int main() { int n, d; cin >> n >> d; vector a(n); for (int i = 0; i < n; i++) cin >> a[i];
}