반응형
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. |
code>>
bool checkPalindrome(std::string inputString) {
int s=0,e = inputString.size() - 1;
while(s <= e)
{
if(inputString[s] != inputString[e])
{
return false;
}
s++;
e--;
}
return true;
}
반응형
'알고리즘 > codefights' 카테고리의 다른 글
6>makeArrayConsecutive2 (0) | 2017.06.28 |
---|---|
5>shapeArea (0) | 2017.06.28 |
4>adjacentElementsProduct (0) | 2017.06.28 |
2>centuryFromYear (0) | 2017.06.28 |
1>add (0) | 2017.06.28 |