PreCompute + BitMask + DP || C++
\n# Code\n\nclass Solution {\npublic:\n    string solve(int last,int mask,int &n,map<int,map<int,int>>&mp,vector<string>&words,vector<vector<string>>&dp){\n    
\n# Code\n```\nclass Solution {\npublic:\n    string solve(int last,int mask,int &n,map<int,map<int,int>>&mp,vector<string>&words,vector<vector<string>>&dp){\n        if(mask==((1<<n)-1)){\n            return "";\n        }\n        if(dp[last+1][mask]!="")\n            return dp[last+1][mask];\n        string curr="";\n        for(int i=0;i<n;i++){\n            if((mask>>i)&1)\n                continue;\n            string temp=words[i].substr(mp[last][i]);\n            temp+=solve(i,mask|(1<<i),n,mp,words,dp);\n            if(curr=="" || temp.size()<curr.size()){\n                curr=temp;\n            }\n        }\n        return dp[last+1][mask]=curr;\n    }\n    string shortestSuperstring(vector<string>& words) {\n        map<int,map<int,int>> mp;\n        int n=words.size();\n        for(int i=0;i<n;i++){\n            mp[-1][i]=0;\n            for(int j=0;j<n;j++){\n                int m=words[i].size();\n                int m2=words[j].size();\n                mp[i][j]=0;\n                for(int l=1;l<=min(m,m2);l++){\n                    string temp=words[i].substr(m-l);\n                    string temp2=words[j].substr(0,l);\n                    if(temp==temp2){\n                        mp[i][j]=l;\n                    }\n                }\n            }\n        }\n        vector<vector<string>> dp(n+1,vector<string>(1<<n,""));\n        return solve(-1,0,n,mp,words,dp);\n    }\n};\n```
['C++']