mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Update 1221.分割平衡字符串.md about TypeScript
This commit is contained in:
@ -156,6 +156,21 @@ var balancedStringSplit = function(s) {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### TypeScript
|
||||||
|
|
||||||
|
```ts
|
||||||
|
function balancedStringSplit(s: string): number {
|
||||||
|
let count: number = 0
|
||||||
|
let res: number = 0
|
||||||
|
for(let i of s){
|
||||||
|
if(i === 'R') count++
|
||||||
|
else count--
|
||||||
|
if(count === 0) res++
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
|
Reference in New Issue
Block a user