Conditions | 5 |
Paths | 7 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
68 | public static function removeElements4(?ListNode $head, int $val): ?ListNode |
||
69 | { |
||
70 | if (!$head) { |
||
71 | return null; |
||
72 | } |
||
73 | $curr = $head; |
||
74 | while ($curr->next) { |
||
75 | if ($curr->next->val === $val) { |
||
76 | $curr->next = $curr->next->next; |
||
77 | } else { |
||
78 | $curr = $curr->next; |
||
79 | } |
||
80 | } |
||
81 | |||
82 | return $head->val === $val ? $head->next : $head; |
||
83 | } |
||
85 |