From bddc4f48ddfbf85d5ebf81d82c41cf85b081c7ea Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Wed, 6 Nov 2024 09:33:27 +0100 Subject: [PATCH] =?UTF-8?q?kt:=20add=20=C2=AB2914.=20Minimum=20Number=20of?= =?UTF-8?q?=20Changes=20to=20Make=20Binary=20String=20Beautiful=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit URL: https://leetcode.com/problems/minimum-number-of-changes-to-make-binary-string-beautiful/ Signed-off-by: Matej Focko --- ...mum-number-of-changes-to-make-binary-string-beautiful.kt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 kt/minimum-number-of-changes-to-make-binary-string-beautiful.kt diff --git a/kt/minimum-number-of-changes-to-make-binary-string-beautiful.kt b/kt/minimum-number-of-changes-to-make-binary-string-beautiful.kt new file mode 100644 index 0000000..adaf36e --- /dev/null +++ b/kt/minimum-number-of-changes-to-make-binary-string-beautiful.kt @@ -0,0 +1,6 @@ +class Solution { + fun minChanges(s: String): Int = + s.chunked(2).map { + if (it[0] != it[1]) 1 else 0 + }.sum() +}