| Conditions | 6 |
| Paths | 12 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | public static function isPalindrome(ListNode $head): bool |
||
| 12 | { |
||
| 13 | $fast = $head; |
||
| 14 | $slow = $head; |
||
| 15 | while ($fast && $fast->next) { |
||
| 16 | $fast = $fast->next->next; |
||
| 17 | $slow = $slow->next; |
||
| 18 | } |
||
| 19 | if ($fast) { |
||
| 20 | $slow = $slow->next; |
||
| 21 | } |
||
| 22 | $fast = $head; |
||
| 23 | $slow = self::helper($slow); |
||
|
|
|||
| 24 | while ($slow) { |
||
| 25 | if ($fast->val !== $slow->val) { |
||
| 26 | return false; |
||
| 27 | } |
||
| 28 | $fast = $fast->next; |
||
| 29 | $slow = $slow->next; |
||
| 30 | } |
||
| 31 | |||
| 32 | return true; |
||
| 33 | } |
||
| 73 |