id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > almostPalindrome37
prev  |  next  |  chance

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)

public int almostPalindrome37(String str, int maxErrs) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy