-1
我解決了這個問題,但在此之前,我正在嘗試其他方法無效。Python鏈表黑客排名
def insert(self,head,data):
if (head == None):
head = Node(data)
else:
current = head
while current != None:
current = current.next
current = Node(data)
return head
這是我做的第一個,然後我做了這個
def insert(self,head,data):
if (head == None):
head = Node(data)
else:
current = head
while True:
if(current.next == None):
current.next = Node(data)
break
current = current.next
return head
這裏是鏈接的問題https://www.hackerrank.com/challenges/30-linked-list
你的問題是什麼? – MooingRawr