simple C++ using dp
\nint minSessions_(int idx, int mask, int left, vector<int>& tasks, int sessionTime, vector<vector<int>>& dp) {\n    \n    if (mask == ((1 << tasks.size()) - 1)
```\nint minSessions_(int idx, int mask, int left, vector<int>& tasks, int sessionTime, vector<vector<int>>& dp) {\n    \n    if (mask == ((1 << tasks.size()) - 1))\n        return 0;\n    \n    if (dp[left][mask] < INT_MAX) return dp[left][mask];\n    \n    int tot = INT_MAX;\n    \n    for (int i = 0; i < tasks.size(); ++i) {\n        if (mask & (1 << i)) continue;\n        if (tasks[i] > left) continue;\n        tot = min(tot, minSessions_(i + 1, mask | (1 << i), left - tasks[i], tasks, sessionTime, dp));\n    }\n    \n    if (tot == INT_MAX)\n        tot = 1 + minSessions_(0, mask, sessionTime, tasks, sessionTime, dp);\n    \n    dp[left][mask] = tot;\n    \n    return tot;\n}\n\nint minSessions(vector<int>& tasks, int sessionTime) {\n    \n    vector<vector<int>> dp(sessionTime + 1, vector<int>(1 << tasks.size(), INT_MAX));\n    \n    return minSessions_(0, 0, 0, tasks, sessionTime, dp);\n    \n}\n```
[]