package leetcode;

/**
 * https://leetcode.com/problems/number-of-good-ways-to-split-a-string/
 */
public class Problem1525 {
    public int numSplits(String s) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1525 prob = new Problem1525();
        System.out.println(prob.numSplits("aacaba")); // 2
        System.out.println(prob.numSplits("abcd")); // 1
        System.out.println(prob.numSplits("aaaaa")); // 4
        System.out.println(prob.numSplits("acbadbaada")); // 2
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -217,368 +217,714 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        Map%3CCharacter, Integer%3E leftMap = new HashMap%3C%3E()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1525 prob = new Problem1525();%0A        System.out.println(prob.numSplits(%22aacaba%22)); // 2%0A        System.out.println(prob.numSplits(%22abcd%22)); // 1%0A        System.out.println(prob.numSplits(%22aaaaa%22)); // 4%0A        System.out.println(prob.numSplits(%22acbadbaada%22)); // 2
+Map%3CCharacter, Integer%3E rightMap = new HashMap%3C%3E();%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            rightMap.put(s.charAt(i), rightMap.getOrDefault(s.charAt(i), 0) + 1);%0A        %7D%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            rightMap.put(s.charAt(i), rightMap.get(s.charAt(i)) - 1);%0A            if (rightMap.get(s.charAt(i)) %3C= 0) %7B%0A                rightMap.remove(s.charAt(i));%0A            %7D%0A            leftMap.put(s.charAt(i), leftMap.getOrDefault(s.charAt(i), 0) + 1);%0A            if (leftMap.size() == rightMap.size()) %7B%0A                answer++;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1525