about | help | code help+videos | done | prefs |
Write a method to determine if a string is "almost" a palindrome. To be "almost" a palindrome means that the string will have no more than maxErrs of characters that do not match up forwards and backwards. Remember that a palindrome is a string that is the same forwards and backwards. So "racecar" is a palindrome with zero errors, but "racecat" is "almost" a palindrome, but is not quite because it has one error. If the number of errors does not exceed maxErrors, return zero. Otherwise return the total number of errors. Please note that the strings will ONLY contain lower-case letters with no spaces. Look at the test data for additional examples. The only string commands you are allowed to use in solving this problem are: .length and .charAt. almostPalindrome37("amanaplanacanalpanama", 0) → 0 almostPalindrome37("book", 1) → 0 almostPalindrome37("abbawasabba", 2) → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy