Skip to content

Commit b4ed200

Browse files
authored
Update 1653-minimum-deletions-to-make-string-balanced.js
1 parent 209ea5c commit b4ed200

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

1653-minimum-deletions-to-make-string-balanced.js

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/**
2+
* @param {string} s
3+
* @return {number}
4+
*/
5+
const minimumDeletions = function(s) {
6+
let res = 0
7+
let cnt = 0
8+
for(let c of s) {
9+
if(c === 'a' && cnt > 0) {
10+
res++
11+
cnt--
12+
} else if(c === 'b') {
13+
cnt++
14+
}
15+
}
16+
17+
return res
18+
};
19+
20+
// another
21+
122
/**
223
* @param {string} s
324
* @return {number}

0 commit comments

Comments
 (0)