2207. Maximize Number of Subsequences in a String
Содержание
class Solution:
def maximumSubsequenceCount(self, text: str, pattern: str) -> int:
res = 0
cnt = Counter()
for c in text:
if c == pattern[1]:
res += cnt[pattern[0]]
cnt[c] += 1
res += max(cnt[pattern[0]], cnt[pattern[1]])
return res