[Python]Easy to understand
\nfrom functools import lru_cache\nfrom itertools import combinations\nfrom collections import Counter\n\nclass Solution:\n    def minimumIncompatibility(self, 
```\nfrom functools import lru_cache\nfrom itertools import combinations\nfrom collections import Counter\n\nclass Solution:\n    def minimumIncompatibility(self, nums: List[int], k: int) -> int:        \n        counter = Counter(nums)\n        num, cnt = counter.most_common(1)[0]\n        if cnt > k: return -1\n        \n        length = len(nums)//k\n        \n        @lru_cache(None)\n        def helper(nums_tuple):\n            if not nums_tuple:\n                return 0\n\n            ans = float(\'inf\')\n            \n            for a in combinations(set(nums_tuple), length):\n                if len(set(a)) < length: continue\n                    \n                remainings = list(nums_tuple)\n                for x in a:\n                    remainings.remove(x)\n                    \n                ans = min(ans, max(a) - min(a) + helper(tuple(remainings)))\n\n            return ans\n        \n        return helper(tuple(nums))\n```
[]