[C++] Easy to understand-Simple code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    vector<vector<string>> req;\n    string merge(string &a, string &b) // a is followed by b (ab)\n    {\n        int n=a.size(), m=b.size(), len=1, idx=0;\n        while(len<=min(n, m))\n        {\n            if(a.substr(n-len)==b.substr(0, len))\n            {\n                idx=len;\n            }\n            len++;\n        }\n        string res=b.substr(idx);\n        return res;\n    }\n    string solve(vector<string> &words, int prev, int mask, int n, vector<vector<string>> &dp)\n    {\n        if(dp[prev][mask]!="") return dp[prev][mask];\n        string res="";\n        int minLen=INT_MAX;\n        for(int i=0; i<n; i++)\n        {\n            if(mask&(1<<i)) continue;\n            string temp=req[prev][i]+solve(words, i, mask|(1<<i), n, dp);\n            if(temp.size()<minLen)\n            {\n                minLen=temp.size();\n                res=temp;\n            }\n        }\n        return dp[prev][mask]=res;\n    }\npublic:\n    string shortestSuperstring(vector<string>& words) \n    {\n        int n=words.size();\n        req.resize(n, vector<string> (n, ""));\n        vector<vector<string>> dp(n, vector<string> ((1<<(n+1)), ""));\n        for(int i=0; i<n; i++)\n        {\n            for(int j=0; j<n; j++)\n            {\n                if(i==j) continue;\n                req[i][j]=merge(words[i], words[j]);\n            }\n        } \n        string ans="";\n        int minLen=INT_MAX;\n        int mask=0;\n        for(int i=0; i<n; i++)\n        {\n            string temp=words[i]+solve(words, i, mask|(1<<i), n, dp);\n            if(temp.size()<minLen)\n            {\n                minLen=temp.size();\n                ans=temp;\n            }\n        } \n        return ans;\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'Bitmask', 'C++']