Search
⌘K

Leetcode 1987. Number of Unique Good Subsequences

Count the number of distinct non-empty subsequences of a binary string (length up to 1e5) that do not have leading zeros except for the single subsequence "0", returning the result modulo 1e9+7. The core challenge is counting unique subsequence patterns under the leading-zero constraint while avoiding duplicates (typically solved with DP/seen-tracking).


Question Timeline

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

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