Java | Arrays | Beats 100%
\nclass Solution {\n    public boolean canFormArray(int[] arr, int[][] pieces) {\n        var cache = new int[101];\n        Arrays.fill(cache, -1);\n\n        
```\nclass Solution {\n    public boolean canFormArray(int[] arr, int[][] pieces) {\n        var cache = new int[101];\n        Arrays.fill(cache, -1);\n\n        int n = arr.length;\n\n        // fill cache with element indexes\n        for (int i = 0; i < n; i++) {\n            cache[arr[i]] = i;\n        }\n\n        for (var piece : pieces) {\n            var nextExpected = cache[piece[0]];\n\n            for (var el : piece) {\n                if (cache[el] == -1 || cache[el] != nextExpected)\n                    return false;\n\n                nextExpected = cache[el] + 1;\n            }\n        }\n\n        return true;  \n    }\n}\n```
['Array', 'Java']