Travelling Salesman Problem python
\nfrom functools import lru_cache #This is used in order to avoid TLE by implementing memoization\n\nclass Solution:\n    def shortestSuperstring(self, words):\
```\nfrom functools import lru_cache #This is used in order to avoid TLE by implementing memoization\n\nclass Solution:\n    def shortestSuperstring(self, words):\n        def makeadj(words):\n            l = len(words)\n            adj = [["" for z in range(l)] for x in range(l)]\n            for i in range(l):\n                for j in range(l):\n                    if i != j:\n                        x = words[i]\n                        y = words[j]\n                        max_overlap = 0\n                        for k in range(1, min(len(x), len(y)) + 1):\n                            if x[-k:] == y[:k]:\n                                max_overlap = k\n                        adj[i][j] = y[max_overlap:]  # Only keep the non-overlapping part\n            return adj\n\n        @lru_cache(None)\n        def sss(bits, cur):\n            if bits == (1 << n) - 1: \n                return ""\n            res = "a" * 240\n            for i in range(n):\n                if (bits & (1 << i)) == 0:\n                    ans = adj[cur][i] + sss(bits | (1 << i), i)\n                    if len(res) > len(ans):\n                        res = ans\n            return res\n        \n        ans = "a" * 240 \n        n = len(words)\n        adj = makeadj(words)\n        for i in range(n):\n            x = words[i] + sss(1 << i, i)\n            if len(x) < len(ans):\n                ans = x\n        return ans\n```
['Bit Manipulation', 'Bitmask', 'Python', 'Python3']