请你解释一下为什么我的代码需要如此多的内存
def new_form(teleport):
d=dict()
for i in teleport.split(','):
h1,h2=i[0],i[1]
d.setdefault(h1,[]).append(h2)
d.setdefault(h2,[]).append(h1)
return d
def telepor(teleports_string):
d=new_form(teleports_string)
queue=[('1','1')]
while queue:
current,path=queue.pop(0)
if len(set(path))==8 and path[-1]=="1":
return path
for each in d[current]:
if (current+each) in path:
continue
queue.append((each,path+each))
输入是字符串类型(“13,14,23,25,34,35,47,56,58,76,68”),我必须找到一种方法抛出此图