Description
Write a recursive Java method that removes adjacent duplicate characters from a String. If two identical characters appear...
Write a recursive Java method that removes adjacent duplicate characters from a String. If two identical characters appear next to each other, keep only one of them in the result.
A simple way to do this recursively is to check the first two characters of a string and if they are the same, keep only 1 and repeat (recursively) for the rest of the string.
removeAdjDuplicate("bookkeeper") → "bokeper"removeAdjDuplicate("Mississippi") → "Misisipi"removeAdjDuplicate("aabbcc") → "abc"String.You may consult the Java documentation for these classes:
Examples:
removeAdjDuplicate("bookkeeper") -> "bokeper"
removeAdjDuplicate("Mississippi") -> "Misisipi"
Your feedback will appear here when you check your answer.