javascript bitmask dp 144ms
\nconst minSessions = (tasks, sessionTime) => {\n    let n = tasks.length;\n    let dp = Array(1 << n).fill(Number.MAX_SAFE_INTEGER);\n    let valid = Array(1 <
```\nconst minSessions = (tasks, sessionTime) => {\n    let n = tasks.length;\n    let dp = Array(1 << n).fill(Number.MAX_SAFE_INTEGER);\n    let valid = Array(1 << n).fill(false);\n    for (let i = 0; i < 1 << n; i++) {\n        let sum = 0;\n        for (let j = 0; j < n; j++) {\n            if (1 & (i >> j)) sum += tasks[j];\n            // OR if (i << ~j < 0) sum += tasks[j];\n        }\n        valid[i] = sum <= sessionTime;\n    }\n    dp[0] = 0;\n    for (let i = 0; i < 1 << n; i++) {\n        for (let j = i; j > 0; j = (j - 1) & i) {\n            if (valid[j]) {\n                dp[i] = Math.min(dp[i], dp[i - j] + 1);\n            }\n        }\n    }\n    return dp[(1 << n) - 1];\n};\n```
['Dynamic Programming', 'Bitmask', 'JavaScript']