3316. Find Maximum Removals From Source String
You are given a string
source
of sizen
, a stringpattern
that is a subsequence ofsource
, and a sorted integer arraytargetIndices
that contains distinct numbers in the range[0, n - 1]
.We define an operation as removing a character at an index
idx
fromsource
such that:
idx
is an element oftargetIndices
.
pattern
remains a subsequence ofsource
after removing the character.Performing an operation does not change the indices of the other characters in
source
. For example, if you remove'c'
from"acb"
, the character at index 2 would still be'b'
.Return the maximum number of operations that can be performed.
A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.
1 | class Solution { |