Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

reverse linked list with python

def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:

    previousNode, currentNode = None, head

    while currentNode:

        temp = currentNode.next
        currentNode.next = previousNode
        previousNode = currentNode
        currentNode = temp

    return previousNode
Source by eolnuha.com #
 
PREVIOUS NEXT
Tagged: #reverse #linked #list #python
ADD COMMENT
Topic
Name
4+2 =