C++ Track First Elements
Since all elements are unique, we can map the first element in pieces to the piece position. Then, we just check if we have the right piece, and if so - try to 
Since all elements are unique, we can map the first element in `pieces` to the piece position. Then, we just check if we have the right piece, and if so - try to fit it.\n\nAs values are within [0..100], we can use an array instead of a hashmap.\n\n```cpp\nbool canFormArray(vector<int>& arr, vector<vector<int>>& pieces) {\n    vector<int> ps(101, -1);\n    for (int i = 0; i < pieces.size(); ++i)\n        ps[pieces[i][0]] = i;\n    for (int i = 0; i < arr.size(); ) {\n        int p = ps[arr[i]], j = 0;\n        if (p == -1)\n            return false;\n        while (j < pieces[p].size())\n            if (arr[i++] != pieces[p][j++])\n                return false;\n    }\n    return true;\n}\n```
[]