Untitled
Anonymous
kotlin
05/20/2022 4:16 PM
544 B
20
Indexable
fun checkSameCharacters(text: String): String {
val map = mutableSetOf<Char>()
var onlyUniqueChars = true
run loop@{
text.forEach {
if (map.contains(it)) {
onlyUniqueChars = false
return@loop
} else {
map.add(it)
}
}
}
return if (onlyUniqueChars) text.reversed() else text
}Editor is loading...