There is a tournament between two teams. The tournament consists of N rounds. Each team has N competitors. Each competitor has a power between a-z and if the power of two competitors matches in a round then that round will going to be drawn. You have to find the maximum number of draw rounds possible.
Each test case contains an Integer N denotes the number of rounds.
Next two lines will contain a string of lowercase letters of length N denoting the power of N competitors of both teams.
The first line of input contains T, denotes the total number of test cases.
- 1 <= T <= 10
- 1 <= N <= 10**5
- String will contain only lowercase alphabet
Output the answer in a new line.
Sample Input 0
2 4 aabc zcaa 5 pqrrs rsptr
Sample Output 0
Testcase 1 –
Possible draw matches are possible between a, a, c.
Testcase 2 –
Possible draw matches are possible between r, s, p, r.
Solution in Python
from collections import Counter for i in range(int(input())): n = int(input()) s1 = dict(Counter(input())) s2 = dict(Counter(input())) count = 0 for j in s1: try: count+=min(s1[j],s2[j]) except KeyError: pass print(count)