Easy

Given a string, check if it can become a palindrome through a case change of some (possibly, none) letters.

Example

  • For inputString = "AaBaa", the output should be
    isCaseInsensitivePalindrome(inputString) = true.

    "aabaa" is a palindrome as well as "AABAA", "aaBaa", etc.

  • For inputString = "abac", the output should be
    isCaseInsensitivePalindrome(inputString) = false.

    All the strings which can be obtained via changing case of some group of letters, i.e. "abac", "Abac", "aBAc" and 13 more, are not palindromes.

Input/Output

  • [execution time limit] 0.5 seconds (c)

  • [input] string inputString

    Non-empty string consisting of English letters.

    Guaranteed constraints:
    4 ≤ inputString.length ≤ 10.

  • [output] boolean

[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

bool isCaseInsensitivePalindrome(char *inputString)
{
	for(int i=0;i<strlen(inputString)/2;i++)
		if(tolower(inputString[i])!=tolower(inputString[strlen(inputString)-i-1]))
			return false;

	return true;
}
728x90

'Codesignal' 카테고리의 다른 글

<Codesignal> HTML End Tag By Start Tag  (0) 2020.04.19
<Codesignal> Find Email Domain  (0) 2020.04.19
<Codesignal> Is Tandem Repeat?  (0) 2020.04.19
<Codesignal> Proper Noun Correction  (0) 2020.04.18
<Codesignal> Enclose In Brackets  (0) 2020.04.18

+ Recent posts