Code
Python3
def numTilePossibilities(self, T: str) -> int:
count = Counter(T)
def bt():
total = 0
for c in count:
if count[c] > 0:
count[c] -= 1
total += 1 + bt()
count[c] += 1
return total
Big O Analysis
-
Runtime
The runtime complexity here is since we are checking all permutations of the string.
-
Memory
The memory usage is since we use the
collections.Counter
object to store character frequencies.
— A