Hi, I am trying to solve this problem but keep on getting NZEC. Can somebody please help here
My Approach.
Trying to get the count of each char in both the strings. Then dividing length of one char in string_b with char, if present, in string_a. The quotient will be the number of string_b which can be made. Trying to get the minimum. (Assumption is one cannot use the char twice)
from collections import Counter
t = int(input())
for j in range(t):
n = input()
string_a = input()
string_b = input()
count_a = dict(Counter(string_a))
count_b = dict(Counter(string_b))
try:
minimum = count_a[string_b[0]] // count_b[string_b[0]]
for i in range(1,len(string_b)):
value = count_a[string_b[i]] // count_b[string_b[i]]
if value < minimum:
minimum = value
print(minimum)
except:
print(0)
created
last reply
- 4
replies
- 959
views
- 2
users
- 1
link