Insert a Node at the Tail of a Linked List

  • + 0 comments

    A Python solution:

    def insertNodeAtTail(head, data):
        new_node = SinglyLinkedListNode(data)
        if head is not None:
            current = head
            while current.next:
                current = current.next
            current.next = new_node
            return head
        return new_node