A singly linked list is a chain of nodes, where each node holds a value and a pointer to the next node. Unlike an array, the nodes are not contiguous — they can live anywhere in memory, connected by references.
Structuur
text
head
|
v
[10|*]--->[20|*]--->[30|null]
val next val next val next
Voorbeeld
python
:
():
.val = val
. =
():
node = Node(val)
node. = head
node
():
cur = head
cur:
cur.val == target:
cur
cur = cur.
