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:
parent
91b451fdfa
commit
6c6b311a4b
1 changed files with 7 additions and 0 deletions
7
kt/delete-characters-to-make-fancy-string.kt
Normal file
7
kt/delete-characters-to-make-fancy-string.kt
Normal 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 = "")
|
||||||
|
}
|
Loading…
Reference in a new issue