"one-liner"
\nfrom functools import lru_cache\n\nclass Solution:\n    @lru_cache(None)\n    def minInsertions(self, s):\n        return(n:=len(s))and 1-(e:=s[0]==s[-1])+min
```\nfrom functools import lru_cache\n\nclass Solution:\n    @lru_cache(None)\n    def minInsertions(self, s):\n        return(n:=len(s))and 1-(e:=s[0]==s[-1])+min(map(self.minInsertions,(s[e:-1],s[1:n-e])))\n```
[]