package leetcode;

/**
 * https://leetcode.com/problems/minimum-number-of-frogs-croaking/
 */
public class Problem1419 {
    public int minNumberOfFrogs(String croakOfFrogs) {
        int answer = 0;
        for (char c : croakOfFrogs.toCharArray()) {
            // TODO
        }
        return answer;
    }

    public static void main(String[] args) {
        Problem1419 prob = new Problem1419();
        System.out.println(prob.minNumberOfFrogs("croakcroak")); // 1
        System.out.println(prob.minNumberOfFrogs("crcoakroak")); // 2
        System.out.println(prob.minNumberOfFrogs("croakcrook")); // -1
        System.out.println(prob.minNumberOfFrogs("croakcroa")); // -1
        System.out.println(prob.minNumberOfFrogs("cccrrroooaaakkk")); // 3
        System.out.println(prob.minNumberOfFrogs("cccrrraooaoakkk")); // -1
    }
}

@@ -205,634 +205,1114 @@
     
-for (char c : croakOfFrogs.toCharArray()) %7B%0A            // TODO%0A        %7D%0A        return answer;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1419 prob = new Problem1419();%0A        System.out.println(prob.minNumberOfFrogs(%22croakcroak%22)); // 1%0A        System.out.println(prob.minNumberOfFrogs(%22crcoakroak%22)); // 2%0A        System.out.println(prob.minNumberOfFrogs(%22croakcrook%22)); // -1%0A        System.out.println(prob.minNumberOfFrogs(%22croakcroa%22)); // -1%0A        System.out.println(prob.minNumberOfFrogs(%22cccrrroooaaakkk%22)); // 3%0A        System.out.println(prob.minNumberOfFrogs(%22cccrrraooaoakkk%22)); // -1
+int cCount = 0;%0A        int rCount = 0;%0A        int oCount = 0;%0A        int aCount = 0;%0A        for (char c : croakOfFrogs.toCharArray()) %7B%0A            if (c == 'c') %7B%0A                cCount++;%0A            %7D else if (c == 'r') %7B%0A                if (cCount %3C= rCount) %7B%0A                    return -1;%0A                %7D%0A                rCount++;%0A            %7D else if (c == 'o') %7B%0A                if (rCount %3C= oCount) %7B%0A                    return -1;%0A                %7D%0A                oCount++;%0A            %7D else if (c == 'a') %7B%0A                if (oCount %3C= aCount) %7B%0A                    return -1;%0A                %7D%0A                aCount++;%0A            %7D else if (c == 'k') %7B%0A                cCount--;%0A                rCount--;%0A                oCount--;%0A                aCount--;%0A                if (cCount %3C 0 %7C%7C rCount %3C 0 %7C%7C oCount %3C 0 %7C%7C aCount %3C 0) %7B%0A                    return -1;%0A                %7D%0A            %7D%0A            answer = Math.max(answer, cCount);%0A        %7D%0A        if (cCount != 0 %7C%7C rCount != 0 %7C%7C oCount != 0 %7C%7C aCount != 0) %7B%0A            return -1;%0A        %7D%0A        return answer;
 %0A   

Solve problem 1419