C++/Python Solution
C++\nRuntime: 8 ms, faster than 58.49% of C++ online submissions for Check Array Formation Through Concatenation.\nMemory Usage: 10.2 MB, less than 76.10% of C+
### C++\n**Runtime: 8 ms, faster than 58.49% of C++ online submissions for Check Array Formation Through Concatenation.\nMemory Usage: 10.2 MB, less than 76.10% of C++ online submissions for Check Array Formation Through Concatenation.**\n```\nclass Solution {\npublic:\n    bool canFormArray(vector<int>& arr, vector<vector<int>>& pieces) \n    {\n        vector<int> ps(101,-1);\n        for(int i=0;i<pieces.size();i++)\n        {\n            ps[pieces[i][0]]=i;\n        }\n        for(int i=0;i<arr.size();)\n        {\n            int p=ps[arr[i]];\n            if(p==-1)\n            {\n                return false;\n            }\n            for(int j=0;j<pieces[p].size();j++)\n            {\n                if(pieces[p][j]!=arr[i++])\n                    return false;\n            }\n        }\n        return true;\n        \n    }\n};\n```\n\n### Python\n```\nclass Solution:\n    def canFormArray(self, arr, pieces):\n        d = {x[0]: x for x in pieces}\n        return list(chain(*[d.get(num, []) for num in arr])) == arr\n```
['C', 'Python', 'C++', 'Python3']