Almost Palindrome
Lesson 2 of 3 in Coddy's Interview Coding Challenges - Pack I course.
A palindrome is a string that reads the same backward or forward.
For example:
"racecar", "mom", "madam" are all palindromes, while "father" isn't.
An almost palindrome is a string that is either a palindrome, or can be turned into a palindrome by changing at most 1 character in it.
For example:
"racecar", "mom", "madam" are all almost palindromes because they are also palindromes.
"racebar" is also an almost palindrome, because it can turn into a palindrome by changing the 'b' character to a 'c' character (or the opposite, changing the 'c' to 'b').
"abcdcab" is not almost a palindrome, because in order to turn into a palindrome, it needs changing in at least 2 characters.
Challenge
MediumWrite a function named isAlmostPalindrome that gets a string as an input, returns true if the string is almost a palindrome, and returns false elsewise.
Try it yourself
#include <stdbool.h>
#include <string.h>
bool isAlmostPalindrome(char* s) {
// Write code here
}