Practice Find Maximum Removals From Source String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Find Maximum Removals From Source String
Problem Statement
Given source, a subsequence pattern, and sorted distinct targetIndices, you may remove characters only at indices in targetIndices while keeping pattern a subsequence. Indices always refer to the original source positions and do not shift after a removal. Return the maximum number of characters that can be removed.
Source: Find Maximum Removals From Source String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
source = "abbaa", pattern = "aba", targetIndices = [0,1,2]
1
# Example 2
source = "bcda", pattern = "d", targetIndices = [0,3]
2
# Example 3
source = "dda", pattern = "dda", targetIndices = [0,1,2]
0
# Example 4
source = "yeyeykyded" , pattern = "yeyyd" , targetIndices = [0,2,3,4]
2
Constraints
Related LeetCode Problems
Practice more problems similar to Find Maximum Removals From Source String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.