Python [k-subset sums]
For a given value of k you can check if you can have k-subsets where none of the sums exceed T. Start from the lowest possible value of k and try if you can sol
For a given value of `k` you can check if you can have `k`-subsets where none of the sums exceed `T`. Start from the lowest possible value of `k` and try if you can solve. `k`-subset sums can be checked with backtracking.\n\n```python\nclass Solution:\n    def minSessions(self, A, T):\n        A.sort(reverse = True)\n        \n        if sum(A) <= T:\n            return 1\n        if min(A) == T:\n            return len(A)\n\n        k_min = sum(A) // T\n        k_max = len(A)\n        \n        for k in range(k_min, k_max):\n            ks = [0] * k\n            \n            def can_partition(j):\n                if j == len(A):\n                    for i in range(k):\n                        if ks[i] > T:\n                            return False\n                    return True\n                for i in range(k):\n                    if ks[i] + A[j] <= T:\n                        ks[i] += A[j]\n                        if can_partition(j + 1):\n                            return True\n                        ks[i] -= A[j]\n                return False\n            \n            if can_partition(0):\n                return k\n        return len(A)\n```
[]