C++|| EASY TO UNDERSTAND || FAST and EFFICIENT || maps
Please upvote to motivate me in my quest of documenting all leetcode solutions(to help the community). HAPPY CODING:)\nAny suggestions and improvements are alwa
**Please upvote to motivate me in my quest of documenting all leetcode solutions(to help the community). HAPPY CODING:)\nAny suggestions and improvements are always welcome**\n```\nclass Solution {\npublic:\n    bool canFormArray(vector<int>& arr, vector<vector<int>>& pieces) {\n        unordered_map<int,vector<int>> mp;\n        for(vector<int> p:pieces)\n        {\n            mp[p[0]]=p;\n        }\n        int i=0;\n        while(i<arr.size())\n        {\n            if(mp.find(arr[i])!=mp.end())\n            {\n                vector<int> piece=mp[arr[i]];\n                for(int j=0;j<piece.size();j++)\n                {\n                if(arr[i]==piece[j])\n                i++;\n                else\n                return false;\n                }\n            }\n            else\n            {\n                return false;\n            }\n        }\n        return true;\n    }\n};\n```
[]