Back to course home
0% completed
Solution: Subsequence Pattern Matching
Problem Statement
Given a string and a pattern, write a method to count the number of times the pattern appears in the string as a subsequence.
Example 1:
Input: string: <span style="color:blue">"baxmx"</span>, pattern: <span style="color:blue">"ax"</span>
Output: <span style="color:green">2</span>
Explanation: {b<span style="color:red">ax</span>mx, b<span style="color:red">a</span>xm<span style="color:red">x</span>}.
Example 2:
Input: string: <span style="color:blue">"tomorrow"</span>, pattern: <span style="color:blue">"tor"</span>
.....
.....
.....
Like the course? Get enrolled and start learning!