Question: Sequential String A special string s of length n consists of characters 0 - 9 only. Its characters can only be accessed sequentially i .
Sequential String
A special string s of length n consists of characters only. Its characters can only be accessed sequentially ie the first chosen is the
leftmost in s There is an array arr of m strings, also consisting of characters Calculate the minimum number of characters
needed from sto construct a permutation of each of the strings in arr
Return an array of integers where the th 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 at that index
Example
Consider ns m arr
To construct Alice needs to access the first characters of the special string and use only and Since the
characters can be rearranged, the results for and are all
To construct access the first characters of the special string and use only and Rearrange to match
String cannot be constructed from the special string. No is available.
The return array is Note that only bolded characters are used to construct the strings.
Function Description
Complete the function countMinimumCharacters in the editor below.
countMinimumCharacters has the following parameters:
string s: the special string of length n
string arrlm: strings to construct
Returns
int: the fth element corresponds to the minimum number of characters required to construct the ith string, or if the string cannot
be constructed
write solution in java
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
