This problem combines
Strings, functions, and arrays. Super fun!
Write a function called
rotateRight that takes a
String as its first argument and a non-negative
its second argument and rotates the
String by the given number of characters.
Here's what we mean by rotate:
CS125rotated right by 1 becomes
CS125rotated right by 2 becomes
CS125rotated right by 3 becomes
CS125rotated right by 4 becomes
CS125rotated right by 5 becomes
CS125rotated right by 8 becomes
And so on.
Notice how characters rotated off the right end of the
String wrap around to the left.
This problem is tricky! Here are a few hints:
Stringto an array of characters before you begin.
charactersback into a
If the passed
String argument is
null, you should return
Good luck and have fun!
Stuck? You may find these lessons helpful: