Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Find the optimal position to add pattern[0] so that the number of subsequences is maximized. Similarly, find the optimal position to add pattern[1].
For each of the above cases, count the number of times the pattern occurs as a subsequence in text. The larger count is the required answer.