Python | TSP | Simple Code with Bit Mask
bitmask: contains information of nodes that are visited currently\ndfs(bitmask, i): shortest superstring after i with visited nodes bitmask\n```\nclass Solution
bitmask: contains information of nodes that are visited currently\ndfs(bitmask, i): shortest superstring after i with visited nodes bitmask\n```\nclass Solution:\n    def shortestSuperstring(self, A):\n        @lru_cache(None)\n        def suffix(i,j):\n            for k in range(min(len(A[i]),len(A[j])),0,-1):\n                if A[j].startswith(A[i][-k:]):\n                    return A[j][k:]\n            return A[j]\n        n = len(A)\n        @lru_cache(None)\n        def dfs(bitmask, i):\n            if bitmask + 1 == 1 << n: return ""\n            return min([suffix(i, j)+dfs(bitmask | 1<<j, j) for j in range(n) if not(bitmask & 1<<j)], key = len)\n        return min([A[i]+dfs(1<<i,i) for i in range(n)], key = len)
['Bit Manipulation', 'Python']