Question 48 (Java)

Given a string, complete the given function to recursively remove the adjacent duplicate characters and return the resultant string. If there are no characters left in the resultant string, return “-1” (without quotes).

Sample Test Cases

Sample Input: ABCCBCBA

Output: ACBA

Explanation: (ABCCBCBA –> ABBCBA –> ACBA)

Sample Input: AA

Sample Output: -1

[advanced_iframe securitykey=”undefined” src=”″ width=”100%” height=”600″]

KodNest Training New Batch is starting on 21st September 2020. Attend one week free demo classes.Register Now

New Report