balanced-brackets java solution