Skip to content

Commit ced9e1f

Browse files
authored
Update 1653-minimum-deletions-to-make-string-balanced.js
1 parent 7e091a3 commit ced9e1f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

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

0 commit comments

Comments
 (0)