Search
⌘K

Leetcode 2207. Maximize Number of Subsequences in a String

Given a text and a length-2 pattern, you may insert either pattern[0] or pattern[1] exactly once anywhere; maximize how many times the pattern appears as a subsequence afterward. The task reduces to counting pattern[0]-before-pattern[1] pairs and choosing the optimal insertion (with a special case when the two pattern characters are identical, where combinations of identical letters determine the result).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.