Kotlinlearncs.online LogoJava
Return to List

Solve: xy Balance

Imported By: Geoffrey Challen
/ Version: 2021.7.0

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.

fun xyBalance(input: String): Boolean {
return false // You may need to remove this starter code
}

Related Lessons

Stuck? You may find these lessons helpful: