Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Removable Characters

med
30 min
Try to solve the Maximum Number of Removable Characters problem.

Statement

You are given two strings s and p, where p is a subsequence of s, along with an array of distinct integers removable representing indices in s.

You want to find the maximum integer k (0≤k≤0 \le k \le removable.length) such that after removing the characters from s at the indices removable[0], removable[1], …, removable[k - 1], p is still a subsequence of s.

Return the maximum possible value of k.

Note: A subsequence of a string is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters.

Constraints:

  • 1≤1 \le p.length ≤\le s.length ≤105\le 10^5

  • 0≤0 \le removable.length << s.length

  • 0≤0 \le removable[i] << s.length

  • p is a subsequence of s.

  • s and p both consist of lowercase English letters.

  • The elements in removable are distinct.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Removable Characters

med
30 min
Try to solve the Maximum Number of Removable Characters problem.

Statement

You are given two strings s and p, where p is a subsequence of s, along with an array of distinct integers removable representing indices in s.

You want to find the maximum integer k (0≤k≤0 \le k \le removable.length) such that after removing the characters from s at the indices removable[0], removable[1], …, removable[k - 1], p is still a subsequence of s.

Return the maximum possible value of k.

Note: A subsequence of a string is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters.

Constraints:

  • 1≤1 \le p.length ≤\le s.length ≤105\le 10^5

  • 0≤0 \le removable.length << s.length

  • 0≤0 \le removable[i] << s.length

  • p is a subsequence of s.

  • s and p both consist of lowercase English letters.

  • The elements in removable are distinct.