Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit03cd2e6

Browse files
authored
Create 1758-minimum-changes-to-make-alternating-binary-string.kt
1 parentca4d5f0 commit03cd2e6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
classSolution {
2+
funminOperations(s:String):Int {
3+
var count=0
4+
5+
for ((i, c)in s.withIndex()) {
6+
if (i%2==0)
7+
count+=if (c=='0')1else0
8+
else
9+
count+=if (c=='1')1else0
10+
}
11+
12+
return minOf(count, s.length- count)
13+
}
14+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp