val = $val; $this->next = $next; } /* 将列表反序列化为链表 */ public static function arrToLinkedList($arr) { $dum = new ListNode(0); $head = $dum; foreach ($arr as $val) { $head->next = new ListNode($val); $head = $head->next; } return $dum->next; } }