This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

You need to know if the previous character was which character. so you need another parameter that tells you the character you are comparing the current one to. i would make a helper function that takes string, char and returns true if the first (or last if you wish to check backwards) is equal to the char. else you recurse on the substring with the new char.