fromList<T> static method
Creates a linked list from a list of values
values - List of values to convert to a linked list
Returns the head of the created linked list
Implementation
static LinkedListNode<T>? fromList<T>(List<T> values) {
if (values.isEmpty) return null;
LinkedListNode<T> head = LinkedListNode<T>(values[0]);
LinkedListNode<T> current = head;
for (int i = 1; i < values.length; i++) {
current.next = LinkedListNode<T>(values[i]);
current = current.next!;
}
return head;
}