增加(0206.翻转链表.md):php版本
This commit is contained in:
parent
b78e750f8f
commit
4405be238d
|
|
@ -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;
|
||||||
|
}
|
||||||
|
```
|
||||||
-----------------------
|
-----------------------
|
||||||
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
|
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue