Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
If both ends have distinct characters, no more operations can be made. Otherwise, the only operation is to remove all of the same characters from both ends. We will do this as many times as we can.
Note that if the length is equal 1 the answer is 1