Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
HackerRank - Algorithms - Warmup - Circular Array Rotation
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void)
int n, k, q;
scanf("%d %d %d", &n, &k, &q);
int arr[n];
for(int i = 0; i < n; i++){
int toprint[q];
for(int i = 0; i < q; i++){
int arr2[n];
for(int i = 0; i < n; i++){
arr2[(i+k)%n] = arr[i];
for(int i = 0; i < q; i++){
printf("%d\n", arr2[(toprint[i])]);

This comment has been minimized.

Copy link
Owner Author

CraigRodrigues commented Aug 4, 2016

It's actually unnecessary to make a second array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.