Code RoomDistinct subsequences
HardPrep Room Coding #925

Distinct subsequences

CodingAlgorithms & data structuresSenior–Staff~35 min

Given two strings s and t (each length 0..1000), return the number of distinct subsequences of s that equal t. A subsequence is formed by deleting zero or more characters without changing the order of the remaining ones; two subsequences are distinct if they use different sets of index positions. The empty string is a subsequence of any string. Return an integer.

Implement
num_distinct(s: str, t: str) → int
Examples
in["rabbbit","rabbit"]out3
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 35 min
InputExpectedGot
["rabbbit","rabbit"]3not run yetsample