data-structures · intermediate · ~15 min

Rotate array right by k

Index arithmetic with modular shifts.

Challenge

Implement void rotate_right(int *a, size_t n, size_t k) that rotates a right by k positions (k may exceed n).

Starter code

#include <stddef.h>
void rotate_right(int *a, size_t n, size_t k) { /* TODO */ }

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.