package leetcode;

/**
 * https://leetcode.com/problems/split-a-string-in-balanced-strings/
 */
public class Problem1221 {
    public int balancedStringSplit(String s) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1221 prob = new Problem1221();
        System.out.println(prob.balancedStringSplit("RLRRLLRLRL")); // 4
        System.out.println(prob.balancedStringSplit("RLLLLRRRLR")); // 3
        System.out.println(prob.balancedStringSplit("LLLLRRRR")); // 1
    }
}

@@ -175,38 +175,52 @@
     
-// TODO%0A        return
+int answer = 0;%0A        int lCount =
  0;%0A    
 %7D%0A%0A 
@@ -219,318 +219,388 @@
     
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1221 prob = new Problem1221();%0A        System.out.println(prob.balancedStringSplit(%22RLRRLLRLRL%22)); // 4%0A        System.out.println(prob.balancedStringSplit(%22RLLLLRRRLR%22)); // 3%0A        System.out.println(prob.balancedStringSplit(%22LLLLRRRR%22)); // 1
+int rCount = 0;%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            if (s.charAt(i) == 'L') %7B%0A                lCount++;%0A            %7D else if (s.charAt(i) == 'R') %7B%0A                rCount++;%0A            %7D%0A            if (lCount == rCount) %7B%0A                answer++;%0A                lCount = 0;%0A                rCount = 0;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1221