kt: add «2914. Minimum Number of Changes to Make Binary String Beautiful»

URL:	https://leetcode.com/problems/minimum-number-of-changes-to-make-binary-string-beautiful/
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-11-06 09:33:27 +01:00
parent 383579f508
commit bddc4f48dd
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -0,0 +1,6 @@
class Solution {
fun minChanges(s: String): Int =
s.chunked(2).map {
if (it[0] != it[1]) 1 else 0
}.sum()
}