Search
⌘K
Get Premium
Leetcode 3351. Sum of Good Subsequences
Compute the total sum of elements over all subsequences of nums that are "good" (every pair of consecutive elements in the subsequence has absolute difference 1), returning the result modulo 1e9+7; due to n and value range up to 1e5 this is solved with a DP that accumulates counts/sums per value rather than enumerating subsequences.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.