Simple Solution
Code
# Code
```cpp []
class Solution {
public:
// map<pair <set <int> , int> , int> mp;
// i have to do bitmasking 
// to chech if some bit in a number is 0 or not 
// (num >> k) & 1 => 1/0
// to set some kth to one use this formulae
// num |= (1 << k)
// you can unset the bit using  num &= ~(1 << k);
// and for the base case all those bits which are one will
// constitute a number which is equal to 2 ^ (size of tasks) - 1;
map <pair <int , int> , int> mp;
vector<vector<int>>dp;
int solve(vector<int>&tasks,int rem,int mask,int sT) {
    // if (st.size() == tasks.size()) {
    //     return 0;
    // }
    if (mask == pow(2 , tasks.size()) - 1) {
        return 0;
    }
    // if (mp.find({st,rem}) != mp.end()) return mp[{st,rem}];
    // if (mp.count({mask , rem})) return mp[{mask,rem}];
    if (dp[mask][rem] != -1) return dp[mask][rem];
    int mn = INT_MAX;
    for (int i = 0; i < tasks.size(); i++) {
        // if (st.find(i) == st.end()) {
            if (((mask >> i) & 1) == 0) {
            if (tasks[i] <= rem) {
                // st.insert(i);
                mask = mask | (1 << i);
                mn = min(mn,solve(tasks,rem-tasks[i],mask,sT));
                // st.erase(i);
                mask &= ~(1 << i);
            }
            // st.insert(i);
            mask = mask | (1 << i);
            mn = min(mn,1+solve(tasks,sT-tasks[i],mask,sT));
            // st.erase(i);
            mask &= ~(1 << i);
        }
    }
    // return mp[{mask,rem}]=mn;
    return dp[mask][rem] = mn;
}
    int minSessions(vector<int>& tasks, int sT) {
        vector<int>v;
        // mn = INT_MAX;
        // set <int> st;
        // return 1 + solve(tasks,sT,st,sT);
        
        dp.assign(pow(2 , tasks.size()) , vector<int>(sT+1 , -1));
        return 1 + solve(tasks,sT,0,sT);
        // return mn;
    }
};
```
![download.jpeg](https://assets.leetcode.com/users/images/aec2e857-535d-4a75-a97d-e4ee405eeeab_1744283164.7962348.jpeg)

['Dynamic Programming', 'Backtracking', 'Bit Manipulation', 'C++']