[C++] DP with Bitmask
\nclass Solution {\npublic:\n    int dp[1<<14+1][16];\n    int solve(vector<int>&tasks, int n, int mask, int time, int t){\n        if(time>t)\n            retu
```\nclass Solution {\npublic:\n    int dp[1<<14+1][16];\n    int solve(vector<int>&tasks, int n, int mask, int time, int t){\n        if(time>t)\n            return INT_MAX;\n        if(mask==0)\n            return 1;\n        if(dp[mask][time]!=-1)\n            return dp[mask][time];\n        \n        //for each task, there are 2 options\n        //include in the ongoing session\n        //start a new session\n        \n        int ans = INT_MAX;\n        for(int i=0;i<n;i++){\n            if(mask & (1<<i)){\n                int ongoing = solve(tasks,n,mask^(1<<i),time+tasks[i],t);\n                int newSession = 1+solve(tasks,n,mask^(1<<i),tasks[i],t);\n                ans = min(ans,min(ongoing,newSession));\n            }\n        }\n        return dp[mask][time] = ans;\n        \n    }\n    int minSessions(vector<int>& tasks, int t) {\n        int n=tasks.size();\n        int mask=(1<<n)-1;\n        memset(dp,-1,sizeof(dp));\n        int ans=solve(tasks,n,mask,0,t);\n        return ans;\n        \n    }\n};\n```
['Recursion', 'C', 'Bitmask', 'C++']