1986. Minimum Sessions ( c++  Dp with Bitmask using pairs)
\ntypedef pair<int,int> pi;\nclass Solution {\npublic:\n    int minSessions(vector<int>& tasks, int sessionTime) {\n        int n=tasks.size();\n        pi mask
```\ntypedef pair<int,int> pi;\nclass Solution {\npublic:\n    int minSessions(vector<int>& tasks, int sessionTime) {\n        int n=tasks.size();\n        pi masks[1<<n];\n        masks[0]=make_pair(1,0);\n        for(int i=1;i<1<<n;i++){\n            masks[i]=pi{n+1,0};\n            for(int j=0;j<n;j++){\n                if((i&(1<<j)) > 0){\n                    int oldmask=i - (1<<j);\n                    pi t = masks[i];\n                    if(masks[oldmask].second+tasks[j] <= sessionTime){\n                        t.first = masks[oldmask].first;\n                        t.second=masks[oldmask].second+tasks[j];\n                    }else{\n                        t.first = masks[oldmask].first+1;\n                        t.second=tasks[j];\n                    }\n                    masks[i]=min(masks[i],t);\n                }\n            }\n        }\n        return masks[(1<<n) - 1].first;\n    }\n};\n```
[]