mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-30 19:08:41 +01:00
20210105
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user