C++ Easy to understand String Concat and Find
Simple Idea:\n\nGiven by constraints that all elements are distinct and the number of elements will be the same we can concatenate the elements in first string 
Simple Idea:\n\nGiven by constraints that all elements are **distinct** and the number of elements will be the same we can concatenate the elements in first string and then compare if all pieces can be found in this string.\n\nThe only case left to handle is:\narr : [85,15]\npieces : [[85][1]]\n\nHere number of elements are the same and both are present in original text BUT they are not the same.\nFor this case we must check the size of both the strings.\n\n\n\n    bool canFormArray(vector<int>& arr, vector<vector<int>>& pieces) {\n        \n        string a="";\n        string b="";\n        int s1 = 0;int s2=0;\n        bool flag =true;\n        \n        //concatenate arr into one single string\n        // [48,18,16] -> "481816"\n        for(int i =0;i<arr.size();i++){\n            a += to_string(arr[i]);\n        }\n        \n        // track the length of the converted string\n        s1 = a.size();\n        \n        //loop through all parts of pieces and concatenate each item\n        //then check if you can find that in the original string\n        for(int i =0;i<pieces.size();i++){\n            \n            for(int j =0;j<pieces[i].size();j++){\n                b += to_string(pieces[i][j]);\n            }\n            \n            // if not found that means break and return false\n            if(a.find(b)==string::npos){\n                flag =false;\n                break;\n            }\n            \n            //keep adding and tracking length of all the strings in pieces.\n            s2 += b.size();\n            b="";\n        }\n        \n        /**\n\t\tif both strings add up to same length, and have same number of \n\t\telements(constraint) and we find through above process that all elements in\n\t\tpieces are present in original text then return true, else false.\n\t\t**/\n        return flag&&(s1==s2);\n    }\n
['String', 'C']