Code RoomDistinct subsequences matching target
HardPrep Room Coding #85

Distinct subsequences matching target

CodingAlgorithms & data structuresSenior–Staff~30 min

Given two strings s and t, count the number of distinct subsequences of s that exactly equal t. A subsequence is formed by deleting zero or more characters without reordering; different sets of deleted positions count as different subsequences even if the resulting string is identical. Return the count; it is guaranteed to fit in a 64-bit signed integer. Both strings contain only English letters and have length up to 1000.

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 30 min
InputExpectedGot
["rabbbit","rabbit"]3not run yetsample