C++: 100% time, 100 % memory
cpp\nclass Solution {\npublic:\n    bool canFormArray(vector<int>& arr, vector<vector<int>>& pieces) {\n        unordered_map<int, int> mp;\n        for (int i 
```cpp\nclass Solution {\npublic:\n    bool canFormArray(vector<int>& arr, vector<vector<int>>& pieces) {\n        unordered_map<int, int> mp;\n        for (int i = 0; i < pieces.size(); ++i) {\n            mp[pieces[i][0]] = i;\n        }\n        \n        int ind = 0;\n        while (ind < arr.size()) {\n            int p = mp[arr[ind]];\n            for (int& x : pieces[p]) {\n                if (x == arr[ind]) {\n                    if (++ind == arr.size()) break;\n                } else {\n                    return false;\n                }\n            }\n        }\n        return true;\n    }\n};\n```
[]