Tap here to switch tabs
Problem
Submissions

Problem: Maximize Number of Subsequences in a String

Try to solve the Maximize Number of Subsequences in a String problem.

Statement

You are given a string text and a string pattern of length 22, both consisting of lowercase English letters.

You can insert either pattern[0] or pattern[1] at any index in text exactly once. The character may be inserted at the beginning, at the end, or between any existing characters of text.

Return the maximum number of times pattern can appear as a subsequence in the modified string.

A subsequence is a string that can be derived from another string by deleting zero or more characters without changing the relative order of the remaining characters.

Constraints:

  • 1≤1 \leq text.length ≤105\leq 10^5

  • pattern.length =2= 2

  • text and pattern consist only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximize Number of Subsequences in a String

Try to solve the Maximize Number of Subsequences in a String problem.

Statement

You are given a string text and a string pattern of length 22, both consisting of lowercase English letters.

You can insert either pattern[0] or pattern[1] at any index in text exactly once. The character may be inserted at the beginning, at the end, or between any existing characters of text.

Return the maximum number of times pattern can appear as a subsequence in the modified string.

A subsequence is a string that can be derived from another string by deleting zero or more characters without changing the relative order of the remaining characters.

Constraints:

  • 1≤1 \leq text.length ≤105\leq 10^5

  • pattern.length =2= 2

  • text and pattern consist only of lowercase English letters.