


The first line of input contains an integer T, the number of test cases.
The first line of each test case contains a single integer ‘N’ denoting the number of strings given.
From the second line onwards the next line ‘N’ lines of the test case contains distinct strings.
Return an integer denoting the minimum number of touches Abhishek has to make to distinguish between all given ‘N’ strings.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
3 <= N <= 10
1 <= k <= 100
Where k is the length of the string.
All the strings are distinct.
Time Limit: 1 sec
Algorithm:-
Approach:-
There are overlapping subcases in Approach1. Hence to optimize it we will use memoization. The memoization state will be dp[mask]. It will tell us the minimum number of touches to make when the state of strings we need to work on is given by mask for all the possible positions. This is similar to memoization with bitmasking. In the count_steps function, we need to add a memoization condition such that if dp[mask]!= -1 then return dp[mask]. In the end dp[mask] = minimum among all the answers for each position.
Algorithm:-