Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Start by counting the frequency of each character and checking if it is possible.
If you take x characters from the left side, what is the minimum number of characters you need to take from the right side? Find this for all values of x in the range 0 ≤ x ≤ s.length.
Use a two-pointers approach to avoid computing the same information multiple times.