| Conditions | 3 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | public static function swapPairs(ListNode $head): ListNode |
||
| 12 | { |
||
| 13 | $dummy = new ListNode(); |
||
| 14 | $dummy->next = $head; |
||
| 15 | $curr = $dummy; |
||
| 16 | |||
| 17 | while (($a = $curr->next) && ($b = $curr->next->next)) { |
||
| 18 | $a->next = $b->next; |
||
| 19 | $curr->next = $b; |
||
| 20 | $curr->next->next = $a; |
||
| 21 | $curr = $curr->next->next; |
||
| 22 | } |
||
| 23 | |||
| 24 | return $dummy->next; |
||
| 25 | } |
||
| 27 |