We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6f3680d commit 319c09bCopy full SHA for 319c09b
1 file changed
Easy/Split a String in Balanced Strings.java
@@ -0,0 +1,13 @@
1
+class Solution {
2
+ public int balancedStringSplit(String s) {
3
+ int count = 0;
4
+ int val = 0;
5
+ for (char c : s.toCharArray()) {
6
+ val += c == 'L' ? -1 : 1;
7
+ if (val == 0) {
8
+ count++;
9
+ }
10
11
+ return count;
12
13
+}
0 commit comments