C++ Solution | Backtracking | Clean and Concise
\nclass Solution {\npublic:\n    int mini;\n    void backtrack(vector<int> tasks,int index,int st,int size,vector<int> count)\n    {\n        if(count.size()>mi
```\nclass Solution {\npublic:\n    int mini;\n    void backtrack(vector<int> tasks,int index,int st,int size,vector<int> count)\n    {\n        if(count.size()>mini)\n            return;\n        if(index==size)\n        {\n            mini=min(mini,(int)count.size() );\n            return;\n        }\n        int sum=accumulate(tasks.begin()+index,tasks.end(),0);\n        for(int i=0;i<count.size();i++)\n        {\n            if(count[i]+sum<=st)\n            {\n                backtrack(tasks,size,st,size,count);\n                return;\n            }\n            if(count[i]+tasks[index]<=st)\n            {\n                count[i]+=tasks[index];\n                backtrack(tasks,index+1,st,size,count);\n                count[i]-=tasks[index];\n            }\n        }\n        count.push_back(tasks[index]);\n        backtrack(tasks,index+1,st,size,count);\n        count.pop_back();\n    }\n    int minSessions(vector<int>& tasks, int sessionTime) \n    {\n        int n=tasks.size();\n        sort(tasks.begin(),tasks.end(),greater<int>());\n        if(accumulate(tasks.begin(),tasks.end(),0)<=sessionTime)\n            return 1;\n        vector<int> count; \n        mini=INT_MAX;\n        backtrack(tasks,0,sessionTime,n,count);\n        return mini;\n    }\n};\n```
[]