Skip to content

Commit

Permalink
1221
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Jan 23, 2022
1 parent 324e95e commit 05299ac
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions E_1221_SplitaStringinBalancedStrings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Solution {
public int balancedStringSplit(String s) {
int count = 0;
int kactane = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'L')
kactane++;
else
kactane--;
if (kactane == 0)
count++;
}

return count;
}
}

0 comments on commit 05299ac

Please sign in to comment.