easy solution beats 90%
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```cpp []\nclass Solution {\npublic:\n    const int inf = 0x3f3f3f3f;\n    int minimumIncompatibility(vector<int>& nums, int k) {\n      int n = nums.size();\n      int sz = n/k; // size of every group\n      //dp(mask, i) select mask, pre select i\n      //if (bit set of mask) == sz, select first available\n      //else select first after i available\n      sort(nums.begin(), nums.end());\n      int dp[1<<n][n];\n      memset(dp, inf, sizeof(dp));\n      for (int i = 0; i < n; ++i) { dp[0][i] = 0; }\n      for (int m = 0; m < (1<<n)-1; ++m) {\n        int cnt = __builtin_popcount(m);\n        for (int i = 0; i < n; ++i) {\n          if (dp[m][i] == inf) { continue; }\n          if (cnt%sz == 0) {\n            int j = __builtin_ffs(~m)-1;\n            dp[m|(1<<j)][j] = min(dp[m|(1<<j)][j],dp[m][i]);\n          } else {\n            for (int j = i+1; j < n; ++j) {\n              if (m&(1<<j) || nums[j] == nums[i]) { continue; }\n              dp[m|(1<<j)][j] = min(dp[m|(1<<j)][j],dp[m][i]+nums[j]-nums[i]);\n            }\n          }\n        }\n      }\n      return dp[(1<<n)-1][n-1] == inf? -1: dp[(1<<n)-1][n-1];\n    }\n};\n```
['C++']