[Python] DFS backtracking pruning (~100 ms)
```\nclass Solution:\n    def minimumIncompatibility(self, nums: List[int], k: int) -> int:\n        f = Counter(nums)\n        if any(f[num] > k for num in f):
```\nclass Solution:\n    def minimumIncompatibility(self, nums: List[int], k: int) -> int:\n        f = Counter(nums)\n        if any(f[num] > k for num in f):\n            return -1\n        bags = [[] for i in range(k)]\n        res = float("inf")\n        n = len(nums)\n        M = n // k\n        nums.sort()\n\t\t\n\t\t###precalculate gaps_sum for pruning\n        s = 0\n\t\tcur = []\n        numbers = sorted(f.keys())\n        gaps = defaultdict(int)\n        gaps_sum =defaultdict(int)\n        for i in range(1,len(numbers)):\n            gaps[numbers[i]] = numbers[i] - numbers[i-1]\n        for i in range(n-1,-1,-1):\n            cur.append(gaps[nums[i]])\n            cur.sort()\n            s += gaps[nums[i]]\n            gaps_sum[i,0] = s\n            for empty in range(1,min(k+1,len(cur))):\n                gaps_sum[i,empty] = gaps_sum[i,empty-1] - cur[-empty]\n        \n\t\t### DFS put #i number in #j bag\n        def DFS(i,cur_res,empty_bags):\n            nonlocal res\n            if i == n:\n                res = min(res,cur_res)\n                return\n            if cur_res + gaps_sum[i,empty_bags] >= res  : \n                return \n            \n            for j in range(k):\n\t\t\t\t### skip when 1. encounter same combination 2. avoid duplicate number in some bags 3. bag is full\n                if (j > 0 and bags[j] == bags[j-1]) or (bags[j] and bags[j][-1] == nums[i]) or (len(bags[j]) == M):\n                    continue\n                else:\n                    bags[j].append(nums[i])\n                    if len(bags[j]) == 1:\n                        DFS(i+1,cur_res,empty_bags-1)\n                    else:\n                        DFS(i+1,cur_res+bags[j][-1]-bags[j][-2],empty_bags)\n                    bags[j].pop()                \n        DFS(0,0,k)\n        return res
[]