Skip to content

Instantly share code, notes, and snippets.

@cust0m
Created April 11, 2017 23:10
Show Gist options
  • Save cust0m/da15223e96dedff5cfa59881a5f765e8 to your computer and use it in GitHub Desktop.
Save cust0m/da15223e96dedff5cfa59881a5f765e8 to your computer and use it in GitHub Desktop.
def isAlmostPalindrome word
return true if word == word.reverse
word.size.times do |index|
('a'..'z').each do |char|
modified_word = word.dup
modified_word[index] = char
return true if modified_word == modified_word.reverse
end
end
return false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment