DIY: Remove All Adjacent Duplicates in String II
Solve the interview question "Remove All Adjacent Duplicates in String II" in this lesson.
We'll cover the following
For this problem, you are given one string
str and an integer
k. Your task is to implement the
removeDuplicates() function. This function will find and remove the
k adjacent duplicate characters in the given
stronly contains lowercase English letters.
removeDuplicates() function will take two inputs:
k. The following is an example of the inputs:
str = akkkabbba k = 2
removeDuplicates() function will return a character string, if there is a character with a count less than
k in the given
str. If there is no character with a count less than
k, then there is no string in the output. The following is the output of the inputs given above:
For this coding exercise, you need to implement the
removeDuplicates = function(str, k) function, wherein
str is a character string and
k is the integer variable.