package leetcode;

/**
 * https://leetcode.com/problems/partition-array-into-disjoint-intervals/
 */
public class Problem915 {
    public int partitionDisjoint(int[] A) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem915 prob = new Problem915();
        System.out.println(prob.partitionDisjoint(new int[]{5, 0, 3, 8, 6})); // 3
        System.out.println(prob.partitionDisjoint(new int[]{1, 1, 1, 0, 6, 12})); // 4
    }
}

@@ -176,15 +176,915 @@
     
-// TODO
+int minIdx = 0;%0A        int maxIdx = 0;%0A        boolean smaller = true;%0A        int i = 1;%0A        int answer = 1;%0A        while (i %3C A.length) %7B%0A            if (smaller) %7B%0A                while (i %3C A.length && A%5Bi%5D %3E= A%5BminIdx%5D) %7B%0A                    if (A%5BminIdx%5D %3E A%5Bi%5D) %7B%0A                        minIdx = i;%0A                    %7D%0A                    if (A%5BmaxIdx%5D %3C A%5Bi%5D) %7B%0A                        maxIdx = i;%0A                    %7D%0A                    i++;%0A                %7D%0A            %7D else %7B%0A                while (i %3C A.length && A%5Bi%5D %3C A%5BmaxIdx%5D) %7B%0A                    if (A%5BminIdx%5D %3E A%5Bi%5D) %7B%0A                        minIdx = i;%0A                    %7D%0A                    if (A%5BmaxIdx%5D %3C A%5Bi%5D) %7B%0A                        maxIdx = i;%0A                    %7D%0A                    i++;%0A                %7D%0A                answer = i;%0A            %7D%0A            smaller = !smaller;%0A            i++;%0A        %7D
 %0A   
@@ -1095,17 +1095,22 @@
  return 
-0
+answer
 ;%0A    %7D%0A
@@ -1199,16 +1199,18 @@
 m915();%0A
+//
         
@@ -1288,94 +1288,731 @@
 / 3%0A
-        System.out.println(prob.partitionDisjoint(new int%5B%5D%7B1, 1, 1, 0, 6, 12%7D)); // 4
+//        System.out.println(prob.partitionDisjoint(new int%5B%5D%7B5, 0, 3, 6, 8%7D)); // 3%0A//        System.out.println(prob.partitionDisjoint(new int%5B%5D%7B1, 1, 1, 0, 6, 12%7D)); // 4%0A//        System.out.println(prob.partitionDisjoint(new int%5B%5D%7B1, 1, 1, 0, 6, 12, 3, 13%7D)); // 4%0A//        System.out.println(prob.partitionDisjoint(new int%5B%5D%7B4, 10, 6, 2, 8, 12%7D)); // 5%0A//        System.out.println(prob.partitionDisjoint(new int%5B%5D%7B5, 5, 3, 8, 2, 10, 9%7D)); // 5%0A//        System.out.println(prob.partitionDisjoint(new int%5B%5D%7B1, 1%7D)); // 1%0A//        System.out.println(prob.partitionDisjoint(new int%5B%5D%7B1, 1, 1, 2, 2, 2%7D)); // 1%0A        System.out.println(prob.partitionDisjoint(new int%5B%5D%7B90, 47, 69, 10, 43, 92, 31, 73, 61, 97%7D)); // 9
 %0A   

Update problem 915