mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
@ -93,6 +93,18 @@ public:
|
||||
## Java
|
||||
|
||||
```java
|
||||
class Solution {
|
||||
public int balancedStringSplit(String s) {
|
||||
int result = 0;
|
||||
int count = 0;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) == 'R') count++;
|
||||
else count--;
|
||||
if (count == 0) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Python
|
||||
|
Reference in New Issue
Block a user