From 4405be238d0041b3cd2719df2945e00fe114c030 Mon Sep 17 00:00:00 2001 From: SevenMonths Date: Tue, 24 May 2022 19:56:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0(0206.=E7=BF=BB=E8=BD=AC?= =?UTF-8?q?=E9=93=BE=E8=A1=A8.md)=EF=BC=9Aphp=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0206.翻转链表.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/problems/0206.翻转链表.md b/problems/0206.翻转链表.md index 941928ba..2e80972c 100644 --- a/problems/0206.翻转链表.md +++ b/problems/0206.翻转链表.md @@ -497,5 +497,20 @@ struct ListNode* reverseList(struct ListNode* head){ } ``` +PHP: +```php +// 双指针法: +function reverseList($head) { + $cur = $head; + $pre = NULL; + while($cur){ + $temp = $cur->next; + $cur->next = $pre; + $pre = $cur; + $cur = $temp; + } + return $pre; +} +``` -----------------------