Maximum Number of Removable Characters
You are given two strings s and p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset of indices of s; s is also 0-indexed.
You want to choose an integer k where 0 <= k <= removable.length such that, after removing k characters from s using the first k indices in removable, p is still a subsequence of s. More formally, you will mark the character at s[removable[i]] for each 0 <= i < k, then remove all marked characters and check whether p is still a subsequence.
Return the maximum k you can choose such that p is still a subsequence of s after the removals.
A subsequence of a string is a new string generated from the original string with some characters, possibly none, deleted without changing the relative order of the remaining characters.
s = "abcacb", p = "ab", removable = [3,1,0]2p is still a subsequence, but removing indices 3, 1, and 0 makes p no longer a subsequence, so the maximum k is 2.s = "abcbddddd", p = "abcd", removable = [3,2,1,4,5,6]1abcd is still a subsequence of the remaining string.Constraints
1 <= p.length <= s.length <= 10^50 <= removable.length < s.length0 <= removable[i] < s.lengthpis a subsequence ofs.sandpboth consist of lowercase English letters.- The elements in
removableare distinct.