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

New Report

Close