C++ DFS with pruning
\nclass Solution {\n    vector<int> tasks;\n    int sessionTime;\n    int result;\n    vector<int> sessions;\n    void dfs(int idx) {\n        if (sessions.size
```\nclass Solution {\n    vector<int> tasks;\n    int sessionTime;\n    int result;\n    vector<int> sessions;\n    void dfs(int idx) {\n        if (sessions.size() >= result) {\n            return;\n        }\n        if (idx == tasks.size()) {\n            result = sessions.size();\n            return;\n        }\n        for (int i = 0; i < sessions.size(); i++) {\n            if (sessions[i] + tasks[idx] <= sessionTime) {\n                sessions[i] += tasks[idx];\n                dfs(idx + 1);\n                sessions[i] -= tasks[idx];\n            }\n        }\n        sessions.push_back(tasks[idx]);\n        dfs(idx + 1);\n        sessions.pop_back();\n    }\npublic:\n    int minSessions(vector<int>& tasks, int sessionTime) {\n        this->tasks = tasks;\n        this->sessionTime = sessionTime;\n        result = tasks.size();\n        dfs(0);\n        return result;\n    }\n};\n```
[]