Skip to main content

Distinct Subsequences

Count distinct subsequences of s that equal t Example: s = "rabbbit", t = "rabbit" => 3 (rabb)b(it), (ra)b(bbit), (rab)b(bit) Example: s = "babgbag", t = "bag" => 5

Distinct Subsequences is about turning repeated work into a reusable state instead of re-solving subproblems. It's a hard one for a reason: it stresses state-and-transition thinking when the rules pile up. Once you define the right state, the transitions usually write themselves.

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit, and to talk with her for one hour. After that, talking comes with the $79 pack. Anyone can open the editor and run their code.

1Count Distinct Subsequenceshard
Based onLeetCode

Get a note when something new lands

New company guides, new problems and big changes to Coco. Rare, and you can leave any time. By joining you agree to get these emails.