parent
18a9fe0f07
commit
78225288cf
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue