Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Can we use brute force to solve the problem?
Repeatedly traverse the string to find and remove the substrings “AB” and “CD” until no more occurrences exist.
Can the solution be optimized using a stack?