Remove characters from consecutive runs of the same character, where the length of the run is greater than the input parameter

Remove characters from consecutive runs of the same character, where the length of the run is greater than the input parameter

Use java and Write a method that takes two parameters, a string and an integer.
The Method will return another string that is similar to the input string, but with certain characters removed.
The code should compile and run with Junits

It’s going to remove characters from consecutive runs of the same character, where the length of the run is greater than the input parameter.

Eg: “aaab”, 2 = “aab”
Eg: “aabb”, 1 = “ab”
Eg: “aabbaa”, 1 = “aba”

Solution:

Java class:

Junit class:

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *