Problem :

https://leetcode.com/problems/letter-tile-possibilities/


My Solution :

class Solution:
def numTilePossibilities(self, tiles):
def dfs(prefix, remain):
if prefix not in ans:
ans.add(prefix)
for i in range(len(remain)):
dfs(prefix + remain[i], remain[:i] + remain[i+1:])

ans = set()
dfs('', tiles)
return len(ans)-1