My issue
why are we writing ans*=(freq[i]+1).Why are we adding that 1 with every element of the frequency array?
My code
from collections import Counter
mod = 10 ** 9 + 7
for _ in range(int(input())):
n = int(input())
s = input()
c = Counter(s)
tot = 0
ans = 0
for v in c.values():
tot += (1 + tot) * v
print(tot % mod)
Problem Link: Beautiful Strings Practice Coding Problem - CodeChef