Sequential String
Frequency: Reported
A string s of length n contains only digits 0 through 9. Its characters are accessible sequentially: the first chosen occurrence of a digit must be its leftmost available occurrence in s.
Given an array arr of m digit strings, return an integer for each target: the minimum prefix length of s containing enough digits to form a permutation of that target. Return -1 if the target cannot be formed.
Example
text
n = 12
s = "064819848398"
m = 3
arr = ["088", "364", "07"]"088"can be formed from the first 7 characters, so its result is7. The same prefix works for any permutation such as"808"or"880"."364"requires the first 10 characters, so its result is10."07"cannot be formed becausescontains no7, so its result is-1.
Return:
text
[7, 10, -1]The function signature and constraints were below the visible portion of the source screenshot and are not preserved.