-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLC2079.py
More file actions
29 lines (25 loc) · 748 Bytes
/
LC2079.py
File metadata and controls
29 lines (25 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Solution(object):
def numTilePossibilities(self, tiles):
"""
:type tiles: str
:rtype: int
"""
if len(tiles) <= 1:
return len(tiles)
self.ans = 0
res = set()
def helper(index,soFar,vis):
#pritn(soFar)
if soFar in res:
return
res.add(soFar)
if len(soFar) >= 1:
self.ans += 1
for i in range(len(tiles)):
if i not in vis:
vis.add(i)
helper(i+1,soFar+tiles[i],vis)
vis.remove(i)
vis = set()
helper(0,"",vis)
return self.ans