很好
你很脑残吗
敢这样用sort
我死也不会放过你
我给你一个选择
1. 我把你送去喝oin的水水
要是敢在这边用sort
你就别怪我不客气了
def removeSubfolders(self, folder: List[str]) -> List[str]:
class Node:
def __init__(self):
self.child = {}
self.isFolder = False
root = Node()
# build Trie
for path in folder:
folders = path.split('/')[1:]
cur = root
for f in folders:
if f in cur.child:
cur = cur.child[f]
else:
cur.child[f] = Node()
cur = cur.child[f]
cur.isFolder = True
# inference
ans = []
def dfs(cur_path, root):
if root.isFolder == True:
ans.append(cur_path)
return
for folder, node in root.child.items():
next_path = cur_path + f"/{folder}"
dfs(next_path, node)
dfs("", root)
return ans