C++ | Simple Backtracking
Algorithm\nBacktracking:\nFor each task, we have two option\n1. To accomodate this task in one of the earlier sessions, given that earlier session time + cur_ta
**Algorithm**\nBacktracking:\nFor each task, we have two option\n1. To accomodate this task in one of the earlier sessions, given that earlier session time + cur_task_time <= max session time.\n2. To create a new session and allocate this task to that session.\n\nWe optimise the backtrack by breaking the recursion if our current session count exceeds that already calculated minimum session count\n\n```\nclass Solution {\npublic:\n    int minSession = INT_MAX;\n    vector<int> sessions;\n    int minSessions(vector<int>& tasks, int sessionTime) \n    {\n        solve(0 ,tasks, sessionTime);\n        return minSession;\n    }\n    \n    void solve(int index, vector<int>& tasks, int target)\n    {\n        // All tasks are scheduled, if sessions is new minimum, update it.\n        if(index >= tasks.size())\n        {\n            if(minSession > sessions.size())\n                minSession = sessions.size();\n            return ;\n        }\n        \n        // if current session count is already greater than our min value, don\'t proceed \n        if(sessions.size() > minSession)\n            return;  \n\t\t\n        //Case 1: Try to fit this task in one of the possible previous sessions.\n        for(int sessionNum = 0; sessionNum < sessions.size(); sessionNum++)\n        {\n            if(sessions[sessionNum] + tasks[index] <= target)\n            {\n                sessions[sessionNum] += tasks[index];\n                solve(index+1, tasks, target);\n                sessions[sessionNum] -= tasks[index];\n            }\n        }\n        \n        //Case 2: Put task as part of new session\n        sessions.push_back(tasks[index]);\n        solve(index+1, tasks, target);\n        sessions.pop_back();        \n    }\n};\n```
[]