kt: add «1957. Delete Characters to Make Fancy String»

URL:	https://leetcode.com/problems/delete-characters-to-make-fancy-string/
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-11-02 00:01:10 +01:00
parent 91b451fdfa
commit 6c6b311a4b
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -0,0 +1,7 @@
class Solution {
fun makeFancyString(s: String): String =
s.windowedSequence(3, partialWindows = true)
.filter { it.length < 3 || it[0] != it[1] || it[1] != it[2] }
.map { it[0] }
.joinToString(separator = "")
}