我的问题是我有一个1->;2->;3->;4->;5的链表
我的概念是像1->;5->;2->;4->;3那样打印它们
意思是先开始后结束
我该怎么做?你知道吗
我有一个想法,那就是首先我拿一个空节点,在空节点中我会继续开始节点,然后
之后,我将遍历到最后一个和结束节点将保持在这里我的大脑停止
有人能指导我做这件事吗?提前谢谢
def mutate_linked_list(head):
#node creation
s = t = Node()
t.next = head
head = head.next
while head is None:
t.next = head
head = head.next
# here i used recursion concept
mutate_linked_list(head)
return head
但它不起作用。。。。你知道吗
很明显,你可以做一个列表,并附加到它,而不是产生值。你知道吗
相关问题 更多 >
编程相关推荐