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″]

Register for the new batch at KodNest and start your journey to success.Secure Your Spot Now!Claim Your Seat

Request A Callback

Get a Free 30-minute Counseling session with our experts.