100% faster c++
class Solution {\npublic:\n    bool canFormArray(vector& arr, vector>& pieces) {\n        \n        int N = arr.size();\n        int M = pieces.size();\n       
class Solution {\npublic:\n    bool canFormArray(vector<int>& arr, vector<vector<int>>& pieces) {\n        \n        int N = arr.size();\n        int M = pieces.size();\n        \n        if(N == 0 || M == 0)\n            return (N == 0);\n        \n        unordered_map<int, int> mp;\n        int idx = 0;\n        \n        for(auto vec : pieces)\n            mp[vec[0]] = idx++;\n        \n        idx = 0;\n        while(idx < N)\n        {\n            if(mp.find(arr[idx]) != mp.end())\n            { \n                for(auto ele : pieces[mp[arr[idx]]])\n                {\n                    if(ele == arr[idx])\n                        idx++;\n                    else\n                        return false;\n                }\n            }\n            else\n                return false;\n        }\n        \n        return idx == N;\n    }\n};
[]