Question bank › Hashing
Dsa Hashing Hard

Count Distinct Subsequences

You are given a string s and a string t. Find the number of distinct subsequences of s which equals t. A subsequence is derived by deleting some or none of the characters from s without changing the order of the remaining characters. Only consider distinct subsequences. Input Format: Two lines: the first line contains the string s, and the second line contains the string t. Output Format: An integer representing the number of distinct subsequences. Example: Input: abc ab Output: 3 (The subsequences are 'ab', 'a*' followed by 'b', and 'a*b'.)

Key concepts

hashingstringsdynamic programming

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.