| Total Complexity | 6 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class ReverseLinkedList |
||
| 10 | { |
||
| 11 | public static function reverseList(?ListNode $head): ?ListNode |
||
| 12 | { |
||
| 13 | if (!$head) { |
||
| 14 | return null; |
||
| 15 | } |
||
| 16 | $node = null; |
||
| 17 | while ($head) { |
||
| 18 | $curr = $head; |
||
| 19 | $head = $head->next; |
||
| 20 | $curr->next = $node; |
||
| 21 | $node = $curr; |
||
| 22 | } |
||
| 23 | |||
| 24 | return $node; |
||
| 25 | } |
||
| 26 | |||
| 27 | public static function reverseList2(?ListNode $head): ?ListNode |
||
| 37 | } |
||
| 38 | } |
||
| 39 |