mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-14 09:59:41 +01:00
15 lines
331 B
Kotlin
15 lines
331 B
Kotlin
|
class Solution {
|
||
|
fun largestGoodInteger(num: String): String = num
|
||
|
.asSequence()
|
||
|
.windowed(3)
|
||
|
.filter { s ->
|
||
|
s[0] == s[1] && s[1] == s[2]
|
||
|
}
|
||
|
.map { window ->
|
||
|
window.joinToString("")
|
||
|
}
|
||
|
.maxByOrNull { num ->
|
||
|
num.toInt()
|
||
|
} ?: ""
|
||
|
}
|