diff --git a/kt/delete-characters-to-make-fancy-string.kt b/kt/delete-characters-to-make-fancy-string.kt new file mode 100644 index 0000000..25efb90 --- /dev/null +++ b/kt/delete-characters-to-make-fancy-string.kt @@ -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 = "") +}