时间复杂度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
时间复杂度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