Sponsored
Use these hints if you're stuck. Try solving on your own first.
Note that it is always more optimal to take one type of substring before another
You can use a stack to handle erasures
Solve with full IDE support and test cases