[C++] Simple C++ Code
\n\n# If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nclass Solution {\n   
\n\n# **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nclass Solution {\n    int n;\n    int dfs(int ctime, vector<vector<int>> &dp, vector<int>& tasks, int stime, int bitmask)\n    {\n        if(bitmask == (1<<n)-1)\n            return 0;\n        if(dp[ctime][bitmask] != -1)\n            return dp[ctime][bitmask];\n        int val = INT_MAX;\n        for(int i = 0; i < n; i++)\n        {\n            if(bitmask & (1 << i))\n                continue;\n            bitmask = (bitmask | (1<<i));\n            if(ctime+tasks[i] <= stime)\n            {\n                val = min(val,dfs(ctime+tasks[i], dp, tasks, stime, bitmask));\n            }\n            else\n            {\n                val = min(val, 1+dfs(tasks[i], dp, tasks, stime, bitmask));\n            }\n            bitmask = (bitmask ^ (1<<i));\n        }\n        return dp[ctime][bitmask] = val;\n    }\n        \npublic:\n    int minSessions(vector<int>& tasks, int sessionTime) {\n        n = tasks.size();\n        vector<vector<int>> dp(sessionTime+1,vector<int>( (1<<tasks.size())-1 , -1));\n        return 1+dfs(0, dp, tasks, sessionTime, 0);\n    }\n};\n```
['Dynamic Programming', 'Backtracking', 'C', 'Bitmask', 'C++']