Search
⌘K

Leetcode 940. Distinct Subsequences II

Count the number of distinct non-empty subsequences of a string modulo 1e9+7. This is typically solved with dynamic programming that doubles the count for each new character but corrects for duplicates by subtracting contributions from the character's previous occurrence (n ≤ 2000, lowercase letters).


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.