I'm a first time poster. I conceded defeat and looked at the answers given on hackkerank itself but the ones I saw used things like vectors, which are concepts I'm a noob at as my knowledge of C++ thus far extends only as far as virtual functions and classes and such (junior COE student). So this is the question..
This is my code, sadly it only works for a few of the test cases, and times out for the others. Any feedback welcome, including suggestions on learning new methods or anything.
int n;
int k;
int q;
cin >> n >> k >> q;
int *arr = new int[n];
int *query = new int[q];
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
for (int j = 0; j < q; j++)
{
cin >> query[j];
}
int *arr2 = new int[n];
int count = 0;
while (count < k)
{
int temp = arr[n - 1];
for (int j = 1; j < n; j++)
{
arr2[j] = arr[j - 1];
}
arr2[0] = temp;
for (int j = 0; j < n; j++)
{
arr[j] = arr2[j];
}
count++;
}
for (int m = 0; m < q; m++)
{
cout << arr2[query[m]] << endl;
}