Solution:
# T:O(n) S:O(1) class Solution: # @param {ListNode} head # @return {ListNode} def reverseList(self, head): dummy = ListNode(float("-inf")) while head: dummy.next, head.next, head = head, dummy.next, head.next return dummy.nextRun Time: 60 ms
No comments:
Post a Comment