Easy
Given the string, check if it is a palindrome.
Example
- For inputString = "aabaa", the output should be
checkPalindrome(inputString) = true; - For inputString = "abac", the output should be
checkPalindrome(inputString) = false; - For inputString = "a", the output should be
checkPalindrome(inputString) = true.
Input/Output
-
[execution time limit] 0.5 seconds (c)
-
[input] string inputString
A non-empty string consisting of lowercase characters.
Guaranteed constraints:
1 ≤ inputString.length ≤ 10^5. -
[output] boolean
- true if inputString is a palindrome, false otherwise.
[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 checkPalindrome(char *inputString)
{
for(int i=0;i<strlen(inputString)/2;i++)
if(inputString[i]!=inputString[strlen(inputString)-i-1])
return false;
return true;
}
728x90
'Codesignal' 카테고리의 다른 글
<Codesignal> almostIncreasingSequence (0) | 2020.04.05 |
---|---|
<Codesignal> shapeArea (0) | 2020.04.05 |
<Codesignal> adjacentElementsProduct (0) | 2020.04.05 |
<Codesignal> centuryFromYear (0) | 2020.04.05 |
<Codesignal> add (0) | 2020.04.05 |