You are viewing a single comment's thread. Return to all comments →
C solution
int string_length (char* str) { int len; for(len = 0; str[len]; len++); return len; } int palindromeIndex(char* s) { int len = string_length(s); for (int counter = 0; counter < len/2; counter++) { if (s[counter] != s[len - 1 - counter]) { if (s[counter] == s[len - 2 - counter]) { if (s[counter + 1] == s[len - 3 - counter]) { return len - 1 - counter; } } return counter; } } return -1; }
Seems like cookies are disabled on this browser, please enable them to open this website
Palindrome Index
You are viewing a single comment's thread. Return to all comments →
C solution