mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-23 18:10:20 +08:00
17 lines
203 B
Go
17 lines
203 B
Go
package leetcode
|
|
|
|
func balancedStringSplit(s string) int {
|
|
count, res := 0, 0
|
|
for _, r := range s {
|
|
if r == 'R' {
|
|
count++
|
|
} else {
|
|
count--
|
|
}
|
|
if count == 0 {
|
|
res++
|
|
}
|
|
}
|
|
return res
|
|
}
|