Search
⌘K

Leetcode 891. Sum of Subsequence Widths

Compute the sum of (max - min) over all non-empty subsequences modulo 1e9+7; the core idea is to sort the array and use combinatorics: each element's contribution as possible maximum vs minimum can be counted by powers of two, avoiding enumerating subsequences.


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.