#3628

Maximum Number of Subsequences After One Inserting

medium · 31.7% accepted · 129 likes · top 9%

string · dynamic programming · greedy · prefix sum

Description

You are given a string s consisting of uppercase English letters.

You are allowed to insert at most one uppercase English letter at any position (including the beginning or end) of the string.

Return the maximum number of "LCT" subsequences that can be formed in the resulting string after at most one insertion.

Solution