C++ | Backtracking with pruning | Beats 95%
```\nclass Solution {\nprivate:\n    void backtrack(vector&tasks,vector&sessionTimes,int &ans,int index,int sessTime){\n    if(sessionTimes.size()>=ans){\n     
```\nclass Solution {\nprivate:\n    void backtrack(vector<int>&tasks,vector<int>&sessionTimes,int &ans,int index,int sessTime){\n    if(sessionTimes.size()>=ans){\n        return;\n    } else if(index>=tasks.size()){\n        ans=min(ans,(int)sessionTimes.size());\n    } else {\n        for(int i=0;i<sessionTimes.size();i++){\n            if(sessionTimes[i]+tasks[index]<=sessTime){\n                sessionTimes[i]=sessionTimes[i]+tasks[index];\n                backtrack(tasks,sessionTimes,ans,index+1,sessTime);\n                sessionTimes[i]=sessionTimes[i]-tasks[index];\n            }\n        }\n        sessionTimes.push_back(tasks[index]);\n        backtrack(tasks,sessionTimes,ans,index+1,sessTime);\n        sessionTimes.pop_back();\n    }\n}\npublic:\n    int minSessions(vector<int>& tasks, int sessionTime) {\n        int ans=tasks.size();\n        vector<int>sess;\n        backtrack(tasks,sess,ans,0,sessionTime);\n        return ans;\n    }\n};
['Backtracking', 'C', 'C++']