Skip to content

Commit 35ff1c6

Browse files
committed
add 926 ts solution
1 parent b72e16a commit 35ff1c6

File tree

1 file changed

+13
-0
lines changed
  • Problems/25-Flip-String-to-Monotone-Increasing

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function minFlipsMonoIncr(s: string): number {
2+
let countOne: number = 0;
3+
let flip: number = 0;
4+
for (let i of s) {
5+
if (i === "1") {
6+
countOne++;
7+
} else {
8+
flip++;
9+
flip = Math.min(countOne, flip);
10+
}
11+
}
12+
return flip;
13+
}

0 commit comments

Comments
 (0)