Standard Java Solution
Theory\nThere are several brute force solutions to this, but the optimal solution will take both linear time and space. We want to take advantage of the fact th
### Theory\nThere are several brute force solutions to this, but the optimal solution will take both linear time and space. We want to take advantage of the fact that the `peices` array will have only distinct integers. I chose to keep a mapping from the first element of the array, to the entire array reference. Then we need to go over the original array, and see if that reference is in the map, if it is, then check each element in our reference to our original array, then continue the loop.\n\n### Solution\n```\n    public boolean canFormArray(int[] arr, int[][] pieces) {\n        Map<Integer, int[]> map = new HashMap<>();\n        for (int[] p : pieces)\n            map.put(p[0], p);\n        \n        int i = 0;\n        while (i < arr.length) {\n            if (!map.containsKey(arr[i])) return false;\n            int[] part = map.get(arr[i]);\n            for (int j = 0; j < part.length; j++) {\n                if (part[j] != arr[i]) return false;\n                i++;\n            }\n        }\n        return true;\n    }\n```
[]