Unique subsequence count
Focus on the count of endWith something
For example.
https://leetcode.com/problems/number-of-unique-good-subsequences/
In this question, we focus on the endWith0, endWith1, while iterating the string, we can update the endWithCount by
if c == '1' endWith1 = endWith0 + endWith1 + 1; // 1 is to sequence with only '1' in the sequence if c =='0' endWith0 = endWith0 + endWith1;
Last updated
Was this helpful?