educative.io

Problem understanding

Hey!
I don’t quite get how result and last are connected. Why when we add Node address to last.next it adds to result.


Type your question above this line.

Course: https://www.educative.io/collection/5642554087309312/5679846214598656
Lesson: https://www.educative.io/collection/page/5642554087309312/5679846214598656/130005

result is the linked list that saves the sum in the same fashion as the addenda. last is the pointer that points to the last node of the result, much like integer1 and integer2 navigate through the linked lists to be added. As result is instantiated as an empty linked list (LinkedListNode* result = nullptr;), we need to create a new node pNew to add to the result and the variable last to remember the address of the last node of result.

1 Like

I see now, thank you!