Junior — Senior
Reverse order of nodes in a singly linked list
livecode
Task condition
A singly linked list is given, each element contains two fields:
value— the value of the node;next— a reference to the next node. It is necessary to implement an algorithm that reverses the links of the list, i.e., the first element becomes the last, and the last becomes the first.
class node{
public $next;
public $value;
}
A->B->C->...->N