Created
April 11, 2017 23:10
-
-
Save cust0m/da15223e96dedff5cfa59881a5f765e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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