mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-24 22:54:43 +01:00
22 lines
301 B
Go
22 lines
301 B
Go
package main
|
|
|
|
func main() {
|
|
|
|
}
|
|
|
|
func countBalance(s string) int {
|
|
count, rCount, lCount := 0, 0, 0
|
|
for i := 0; i < len(s); i++ {
|
|
if s[i] == 'R' {
|
|
rCount++
|
|
} else if s[i] == 'L' {
|
|
lCount++
|
|
}
|
|
if rCount > 0 && rCount == lCount {
|
|
lCount, rCount = 0, 0
|
|
count++
|
|
}
|
|
}
|
|
return count
|
|
}
|