Could someone please explain where these 3 integers come from in this problem? **NO SOLUTIONS PLS**

I'm looking at the list node class and it has an int value, but the question is saying that ListNode l1 has the values [2,4,3]. I don't understand. The structure doesn't make any sense to me. Could someone please explain? I haven't used linked lists before, I only know what they are at a surface level
No description
11 Replies
OnlyOneUnlucky
OnlyOneUnluckyOP2w ago
Please no solutions to the actual problem though, I'd like to solve that myself!
Jimmacle
Jimmacle2w ago
are you familiar with how linked lists work?
OnlyOneUnlucky
OnlyOneUnluckyOP2w ago
All I really know about them is that the elements point to the next in the linked lists, not much else
Jimmacle
Jimmacle2w ago
right, so if you're given the head node to a list containing [2, 4, 3] you will have to traverse the list by reading the value from the head node, going to the next node, getting the value from that node, going to the next node, and so on
OnlyOneUnlucky
OnlyOneUnluckyOP2w ago
That much I understand
Jimmacle
Jimmacle2w ago
well, that's where the values come from
OnlyOneUnlucky
OnlyOneUnluckyOP2w ago
I guess maybe I misread the question - I thought somehow ListNode l1 was equal [2,4,3]
Jimmacle
Jimmacle2w ago
i mean, that linked list does contain those numbers but you're only given a reference to the first node in the list
OnlyOneUnlucky
OnlyOneUnluckyOP2w ago
i think thats where i got tripped up
OlujA
OlujA2w ago
glad i read this before i hit enter :PepeLaugh:
OnlyOneUnlucky
OnlyOneUnluckyOP2w ago
@Jimmacle thanks for the help!

Did you find this page helpful?