Skip to content

Commit 57583ab

Browse files
committed
add 1221 ts solution
1 parent 52daf33 commit 57583ab

File tree

1 file changed

+14
-0
lines changed
  • Problems/17-Split-a-String-in-Balanced-Strings

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+
function balancedStringSplit(s: string): number {
2+
let res: number = 0;
3+
let x:number = 0;
4+
5+
for(let i of s) {
6+
if( i === 'R') x++;
7+
else x--;
8+
9+
if(x === 0) {
10+
res ++;
11+
}
12+
}
13+
return res;
14+
};

0 commit comments

Comments
 (0)