Dsa
Hashing
Medium
Subsequence Count
Count how many times a given word appears as a subsequence in a string. A subsequence is a sequence that appears in the same relative order but not necessarily contiguous.
Input:
Two strings, the first is the main string and the second is the subsequence to count.
Output:
An integer representing the count of occurrences of the subsequence in the main string.
Example:
Input:
'ababcababc' 'abc'
Output:
5
Key concepts
hashingstringssubsequences
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