Search
⌘K

Leetcode 2681. Power of Heroes

Compute the sum over all non-empty subsets of nums of (max(subset)^2 * min(subset)) modulo 1e9+7. With n up to 1e5 you must avoid enumerating subsets and instead use sorting plus combinatorial counting (powers of two) to accumulate each element’s contribution as max/min efficiently.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.