We'll say that a String
is xy-balanced if for all the 'x' characters there exists a 'y' character
later in the string.
So "xxy" is balanced, but "xyx" is not.
One 'y' can balance multiple 'x's.
Return true
if the given String
is xy-balanced.
Stuck? You may find these lessons helpful: