Easy

Define an alphabet reflection as follows: a turns into z, b turns into y, c turns into x, ..., n turns into m, m turns into n, ..., z turns into a.

Define a string reflection as the result of applying the alphabet reflection to each of its characters.

Reflect the given string.

Example

For inputString = "name", the output should be
reflectString(inputString) = "mznv".

Input/Output

  • [execution time limit] 0.5 seconds (c)

  • [input] string inputString

    A string of lowercase characters.

    Guaranteed constraints:
    3 ≤ inputString.length ≤ 1000.

  • [output] string

[C] Syntax Tips

// Prints help message to the console
// Returns a string
char * helloWorld(char * name) {
    char * answer = malloc(strlen(name) + 8);
    printf("This prints to the console when you Run Tests");
    strcpy(answer, "Hello, ");
    strcat(answer, name);
    return answer;
}

더보기

Solution

char *reflectString(char *inputString)
{
	for(int i=0;i<strlen(inputString);i++)
		inputString[i]='a'+'z'-inputString[i];

	return inputString;
}
728x90

'Codesignal' 카테고리의 다른 글

<Codesignal> Cipher 26  (0) 2020.05.29
<Codesignal> New Numeral System  (0) 2020.05.24
<Codesignal> Character Parity  (0) 2020.05.24
<Codesignal> Three Split  (0) 2020.05.24
<Codesignal> Ada Number  (0) 2020.05.23

+ Recent posts