Tap here to switch tabs
Problem
Submissions

Problem: Find Maximum Removals From Source String

med
30 min
Try to solve the Find Maximum Removals From Source String problem.

Statement

You are given a string source, a string pattern, and an integer array targetIndices sorted in ascending order.

You can choose to remove characters from source at indices present in targetIndices.

Return the maximum number of indices from targetIndices that can be removed such that pattern remains a subsequence of source after all removals.

Constraints:

  • 1≤n=1 \le n = source.length ≤3imes103\le 3 imes 10^3

  • 1≤1 \le pattern.length ≤n\le n

  • 1≤1 \le targetIndices.length ≤n\le n

  • targetIndices is sorted in ascending order.

  • targetIndices contains distinct elements in the range [0,n−1][0, n - 1].

  • source and pattern consist only of lowercase English letters.

  • pattern is guaranteed to be a subsequence of source.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Maximum Removals From Source String

med
30 min
Try to solve the Find Maximum Removals From Source String problem.

Statement

You are given a string source, a string pattern, and an integer array targetIndices sorted in ascending order.

You can choose to remove characters from source at indices present in targetIndices.

Return the maximum number of indices from targetIndices that can be removed such that pattern remains a subsequence of source after all removals.

Constraints:

  • 1≤n=1 \le n = source.length ≤3imes103\le 3 imes 10^3

  • 1≤1 \le pattern.length ≤n\le n

  • 1≤1 \le targetIndices.length ≤n\le n

  • targetIndices is sorted in ascending order.

  • targetIndices contains distinct elements in the range [0,n−1][0, n - 1].

  • source and pattern consist only of lowercase English letters.

  • pattern is guaranteed to be a subsequence of source.