package leetcode;

/**
 * https://leetcode.com/problems/largest-time-for-given-digits/
 */
public class Problem949 {
    public String largestTimeFromDigits(int[] A) {
        // TODO
        return "";
    }

    public static void main(String[] args) {
        Problem949 prob = new Problem949();
        System.out.println(prob.largestTimeFromDigits(new int[]{1, 2, 3, 4})); // 23:41
        System.out.println(prob.largestTimeFromDigits(new int[]{5, 5, 5, 5})); //
    }
}

@@ -173,33 +173,1028 @@
     
-// TODO%0A        return %22%22
+boolean%5B%5D processed = new boolean%5BA.length%5D;%0A        int t1 = time(A, processed, 2);%0A        if (t1 == -1) %7B%0A            return %22%22;%0A        %7D%0A        int t2 = time(A, processed, t1 %3C 2 ? 9 : 3);%0A        if (t2 == -1) %7B%0A            return %22%22;%0A        %7D%0A        int t3 = time(A, processed, 5);%0A        if (t3 == -1) %7B%0A            return %22%22;%0A        %7D%0A        int t4 = time(A, processed, 9);%0A        if (t4 == -1) %7B%0A            return %22%22;%0A        %7D%0A        return String.format(%22%25d%25d:%25d%25d%22, t1, t2, t3, t4);%0A    %7D%0A%0A    private static int time(int%5B%5D a, boolean%5B%5D processed, int val) %7B%0A        int max = -1;%0A        int idx = -1;%0A        for (int i = 0; i %3C a.length; i++) %7B%0A            if (processed%5Bi%5D) %7B%0A                continue;%0A            %7D%0A            if (a%5Bi%5D %3C= val) %7B%0A                if (max %3C a%5Bi%5D) %7B%0A                    idx = i;%0A                    max = a%5Bi%5D;%0A                %7D%0A            %7D%0A        %7D%0A        if (idx == -1) %7B%0A            return -1;%0A        %7D%0A        processed%5Bidx%5D = true;%0A        return a%5Bidx%5D
 ;%0A  
@@ -1287,16 +1287,18 @@
 m949();%0A
+//
         
@@ -1377,16 +1377,18 @@
 / 23:41%0A
+//
         
@@ -1461,16 +1461,734 @@
 %7D)); //%0A
+//        System.out.println(prob.largestTimeFromDigits(new int%5B%5D%7B5, 0, 3, 2%7D)); // 23:50%0A//        System.out.println(prob.largestTimeFromDigits(new int%5B%5D%7B5, 0, 3, 2%7D)); // 23:50%0A//        System.out.println(prob.largestTimeFromDigits(new int%5B%5D%7B0, 0, 0, 2%7D)); // 23:50%0A//        System.out.println(prob.largestTimeFromDigits(new int%5B%5D%7B0, 4, 0, 0%7D)); // 04:00%0A//        System.out.println(prob.largestTimeFromDigits(new int%5B%5D%7B0, 4, 0, 9%7D)); // 04:00%0A//        System.out.println(prob.largestTimeFromDigits(new int%5B%5D%7B2, 3, 6, 2%7D)); // 23:26%0A//        System.out.println(prob.largestTimeFromDigits(new int%5B%5D%7B4, 1, 0, 0%7D)); // 14:00%0A        System.out.println(prob.largestTimeFromDigits(new int%5B%5D%7B2, 0, 6, 6%7D)); // 06:26%0A
     %7D%0A%7D%0A

Update problem 949