C++ Easy To Read Memo Bitmask
Code


# Code
```cpp []
class Solution {
public:
    int set = 0;
    int recur(vector<int>& tasks, int mask, int session, vector<vector<int>>& dp) {
        if (mask==pow(2,tasks.size())-1) {
            return 0;
        }

        if (dp[mask][session]!=-1) {
            return dp[mask][session];
        }

        int res = INT_MAX-1000;

        for (int i = 0;i<tasks.size();i++) {
            if (!(mask&(1<<i))) {
                if (session-tasks[i]<0) {
                res = min(res,1+recur(tasks,mask|(1<<i),set-tasks[i],dp));
                } else {
                    res = min(res,recur(tasks,mask|(1<<i),session-tasks[i],dp));
                }
            }
            
        }
        return dp[mask][session]=res;
    }

    int minSessions(vector<int>& tasks, int sessionTime) {
        set = sessionTime;
        vector<vector<int>> dp(pow(2,tasks.size()),vector<int>(sessionTime+1,-1));



        return 1+recur(tasks,0,set,dp);
    }
};
```
['Array', 'Dynamic Programming', 'Backtracking', 'Bit Manipulation', 'Bitmask', 'C++']