Company: Service now_26oct
Difficulty: medium
Count Minimum Characters Problem Description You are given a string s of length n made only of the digits 0 to 9 . The characters of s can only be taken in order from its beginning: when you need a digit, you take its leftmost occurrence that you have not used yet. You are also given an array arr of m strings, each made only of digits. For each string arr[i] , find the minimum number of characters that must be taken from the beginning of s so that some permutation of arr[i] can be formed from them. In other words, find the smallest L such that the prefix s[1..L] contains every digit at least as many times as it appears in arr[i] . If even the whole of s is not enough, the answer for arr[i] is -1 . Each string of arr is answered on its own: the characters used for one string are available again for the next one. Function Description Complete the function countMinimumCharacters : vector<int> countMinimumCharacters(string s, vector<string> arr) s : the digit string of length n