Python (Simple DP)
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    def minimumIncompatibility(self, nums, k):\n        length = len(nums)//k\n        \n        @lru_cache(None)\n        def dfs(nums):\n            if not nums: return 0\n            \n            min_val = float("inf")\n            \n            for i in itertools.combinations(nums,length):\n                if len(set(i)) < length: continue\n                    \n                new_nums = list(nums)\n                \n                for j in i:\n                    new_nums.remove(j)\n                    \n                min_val = min(min_val,max(i)-min(i)+dfs(tuple(new_nums)))\n                \n            return min_val\n        \n        result = dfs(tuple(nums))\n        \n        return result if result != float("inf") else -1\n\n            \n        \n        \n\n\n```
['Python3']