Removing Duplicates in a String
Learn how to remove duplicates in a string using recursion.
We'll cover the following...
We'll cover the following...
What does removing duplicates mean?
When given a string that has repeating adjacent characters, we only want to keep one of each character. To do this, we must eliminate the repeating characters.
The illustration below shows this process.
Implementing the code
The code below shows how to do this with recursion. First, let’s see the code, and then we will go on to its explanation.
Try the code by changing the value of text to see how it works with other strings.
Understanding the code
The recursive code can be broken down into two parts: the recursive method and the main method where ...