We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ce89a3e + 2cf8ee5 commit e8d1a1aCopy full SHA for e8d1a1a
problems/0206.翻转链表.md
@@ -496,8 +496,26 @@ struct ListNode* reverseList(struct ListNode* head){
496
return reverse(NULL, head);
497
}
498
```
499
-Scala:
500
+
501
502
+PHP:
503
+```php
504
+// 双指针法:
505
+function reverseList($head) {
506
+ $cur = $head;
507
+ $pre = NULL;
508
+ while($cur){
509
+ $temp = $cur->next;
510
+ $cur->next = $pre;
511
+ $pre = $cur;
512
+ $cur = $temp;
513
+ }
514
+ return $pre;
515
516
+```
517
518
+Scala:
519
双指针法:
520
```scala
521
object Solution {
@@ -529,6 +547,7 @@ object Solution {
529
547
cur.next = pre
530
548
reverse(cur, tmp) // 此时cur成为前一个节点,tmp是当前节点
531
549
550
532
551
533
552
534
553
-----------------------
0 commit comments