剑指offer 第15题
剑指offer第15题,python实现:
class Solution:
# 返回ListNode
def ReverseList(self, pHead):
# write code here
if pHead==None or pHead.next==None:
return pHead
else:
qlist = []
listNode = pHead
while(listNode!=None):
qlist.append(listNode)
listNode = listNode.next
qHead = ListNode(qlist.pop())
W = qHead
while(len(qlist)>0):
listNode1 = ListNode(qlist.pop())
W.next = listNode1
W = listNode1
return qHead
在本机运行没问题,提交显示{%d format: a number is required, not instance 的错误
请问怎么解决?