Simple Iterative Python Solutiion, beats 99.66%


  • 0
    C

    class Solution(object):
    def reverseList(self, head):
    """
    :type head: ListNode
    :rtype: ListNode
    """
    if head == None:
    return
    current = head
    last = None
    while (current is not None):
    next = current.next
    current.next = last
    last = current
    current = next
    return last


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.