时间复杂度O(n)
class Solution:
# 返回ListNode
def ReverseList(self, pHead):
# write code here
if not pHead:
return None
root = None
while pHead:
pHead.next,root,pHead = root,pHead,pHead.next
return root
京公网安备 11010502036488号