Sequential String
A special string of length n consists of characters 0-9 only. Its characters can only be accessed sequentially i.e the first '1' chosen is the leftmost '1' in s. There is an array arr of m strings, also consisting of characters 0-9. Calculate the minimum number of characters needed from s to construct a permutation of each of the strings in arr.
Return an array of integers where the ith element denotes the minimum length of a substring that contains a permutation of the ith string in arr. If a string cannot be constructed, return -1 at that index.
Complete the function countMinimumCharacters in the editor below.
countMinimumCharacters has the following parameters:
String s: the special string of lengthnString[] arr: an array of strings
Returns
int[]: an array of integers where each element denotes the minimum length of a substring needed to construct a permutation of the string at that index in arr, or -1 if it cannot be constructed
1Example 1
n=12, s="064819848398", m=3, arr=["088", "364", "07"]:
[7, 10, -1]. Note that only bolded characters are used to construct the strings.Constraints
Limits and guarantees your solution can rely on.