FunctionRacerProblemsRace

Caesar Cipher

EasyStringsPython, JavaScript, TypeScript, Java, C++

Shift every letter of s forward by k places in the alphabet, wrapping from z back to a (and Z to A). Keep upper and lower case, and leave characters that are not letters unchanged.

If k is negative, shift backward instead.

Example 1

s "abc xyz"
k 3
returns "def abc"

def abc.

Example 2

s "Hi!"
k -1
returns "Gh!"

Backward by one: Gh!.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems