Company: Different.ai
Difficulty: medium
Erasing Order You are given two lowercase strings t and p , and a removal order for the characters of t . The removal order is a permutation a1, a2, ..., a|t| of the indices 1, 2, ..., |t| . If you decide to perform k removals, you delete exactly the characters at positions a1, a2, ..., ak , in that order - you may not skip a position or reorder them. Deleting a character never renumbers anything: every surviving character keeps its original index. You want p to still be obtainable from what is left. That is, after the k removals, p must be a subsequence of the string formed by the surviving characters read left to right. Find the largest k for which this is still possible. Input The first line contains the string t . The second line contains the string p . The third line contains |t| space-separated integers a1, a2, ..., a|t| - a permutation of 1, 2, ..., |t| giving the removal order. Output Print a single integer: the maximum number of characters that can be removed while p remains o