From 6c6b311a4b4ced1ba3dcb889b9fb1116bdb11c78 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sat, 2 Nov 2024 00:01:10 +0100 Subject: [PATCH] =?UTF-8?q?kt:=20add=20=C2=AB1957.=20Delete=20Characters?= =?UTF-8?q?=20to=20Make=20Fancy=20String=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit URL: https://leetcode.com/problems/delete-characters-to-make-fancy-string/ Signed-off-by: Matej Focko --- kt/delete-characters-to-make-fancy-string.kt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 kt/delete-characters-to-make-fancy-string.kt 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 = "") +}