Question 18 Max score: 50.00 3 7 Ctgoc 10:3 1> #inc 4 5 6 7>} long String selection…
- User
Question 18
Max score: 50.00
3
7
Ctgoc 10:3
1> #inc
4
5
6
7>}
long
String selection
Given N strings. Each string is given in the form of an array cnt of size 26, where element in array denotes the count of of lowercase English alphabets in the string character
You have to select exactly 4 strings and insert the strings into a Trie You can are allowed to shuffle the characters in each string
Find the minimum number of nodes present in Trie if the strings are selected optimally
Notes
Trie will always have a root node. Include the root node in the count of nodes present in Trie.
Insertion proceeds by walking the Trie according to the string to be inserted, then appending new nodes for the suffix of the string that is not contained in the Trie.
Function description
Complete the solve function. This function takes the following 2 parameters and returns the required answer:
N. Represents the number of strings
crit: Represents a 2D array representing the count of each lowercase English alphabet in the string. It has dimension N°26
<Previous Question
Next Question>Complete the sove luncuon, this tuncoon takes the following z parameters and returns the required answer:
N. Represents the number of strings
cnt. Represents a 2D array representing the count of each lowercase English alphabet in the string. It has dimension N°26
Input format for custom testing
Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code.
The first line contains T, which represents the number of test cases.
For each test case:
• The first line contains an integer N.
• The next lines contain 26 space-separated integers denoting the count of each lowercase English alphabet in the string.
Output format
For each test case, print the minimum number of nodes present in Trie in a new line.
Constraints
1<T<5
4≤ N ≤20
0 ≤ cnt[i][j] < 105
- Assistant