C++ Implementation using DP with Bitmasking
\n\n# Code\n\nclass Solution {\npublic:\n    int dp[16385][16];\n    int f(int mask,vector<int>& tasks, int sessionTime,int curr=0){\n        if(mask==((1<<task
\n\n# Code\n```\nclass Solution {\npublic:\n    int dp[16385][16];\n    int f(int mask,vector<int>& tasks, int sessionTime,int curr=0){\n        if(mask==((1<<tasks.size()) - 1)){\n            return 1;\n        }\n        if(dp[mask][curr]!=-1){\n            return dp[mask][curr];\n        }\n        int ans=1e9;\n        for(int i=0;i<tasks.size();i++)\n        {\n            if(!((1<<i) & (mask))){\n                if(curr+tasks[i]<=sessionTime){\n                    ans=min(ans,f((mask | (1<<i)),tasks,sessionTime,curr+tasks[i]));\n                }\n                else{\n                    ans=min(ans,1+f((mask | (1<<i)),tasks,sessionTime,tasks[i]));\n                }\n            }\n        }\n        return dp[mask][curr]=ans;\n    }\n    int minSessions(vector<int>& tasks, int sessionTime) {\n        int mask=0;\n        memset(dp,-1,sizeof(dp));\n        int ans= f(mask,tasks,sessionTime);\n        return ans;\n    }\n};\n```
['Dynamic Programming', 'Bit Manipulation', 'Bitmask', 'C++']