parent
18a9fe0f07
commit
78225288cf
|
|
@ -93,6 +93,18 @@ public:
|
||||||
## Java
|
## Java
|
||||||
|
|
||||||
```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
|
## Python
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue