package leetcode;

/**
 * https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array/
 */
public class Problem1764 {
    public boolean canChoose(int[][] groups, int[] nums) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1764 prob = new Problem1764();
        System.out.println(prob.canChoose(new int[][]{
            {1,-1,-1},{3,-2,0}
        }, new int[]{1,-1,0,1,-1,-1,3,-2,0})); // true
        System.out.println(prob.canChoose(new int[][]{
            {10,-2},{1,2,3,4}
        }, new int[]{1,2,3,4,10,-2})); // false
        System.out.println(prob.canChoose(new int[][]{
            {1,2,3},{3,4}
        }, new int[]{7,7,1,2,3,4,7,7})); // false
    }
}

@@ -207,540 +207,760 @@
     
-// TODO%0A        return false
+boolean answer = true;%0A        int i = 0
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1764 prob = new Problem1764();%0A        System.out.println(prob.canChoose(new int%5B%5D%5B%5D%7B%0A            %7B1,-1,-1%7D,%7B3,-2,0%7D%0A        %7D, new int%5B%5D%7B1,-1,0,1,-1,-1,3,-2,0%7D)); // true%0A        System.out.println(prob.canChoose(new int%5B%5D%5B%5D%7B%0A            %7B10,-2%7D,%7B1,2,3,4%7D%0A        %7D, new int%5B%5D%7B1,2,3,4,10,-2%7D)); // false%0A        System.out.println(prob.canChoose(new int%5B%5D%5B%5D%7B%0A            %7B1,2,3%7D,%7B3,4%7D%0A        %7D, new int%5B%5D%7B7,7,1,2,3,4,7,7%7D)); // false
+for (int%5B%5D group : groups) %7B%0A            int j = 0;%0A            int k = i;%0A            boolean found = false;%0A            while (j %3C group.length && i %3C nums.length) %7B%0A                while (i %3C nums.length && group%5Bj%5D != nums%5Bi%5D) %7B%0A                    i++;%0A                %7D%0A                for (; j %3C group.length && i %3C nums.length; i++, j++) %7B%0A                    if (group%5Bj%5D != nums%5Bi%5D) %7B%0A                        i = k++ + 1;%0A                        j = 0;%0A                        break;%0A                    %7D%0A                %7D%0A                if (j == group.length) %7B%0A                    found = true;%0A                %7D%0A            %7D%0A            answer &= found;%0A        %7D%0A        return answer;
 %0A   

Solve problem 1764