Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a504557

Browse files
committed
Feat: leetcode-83
1 parent 108189a commit a504557

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## 题目
2+
3+
## 思路
4+
5+
## 代码
6+
7+
```php
8+
/**
9+
* Definition for a singly-linked list.
10+
* class ListNode {
11+
* public $val = 0;
12+
* public $next = null;
13+
* function __construct($val = 0, $next = null) {
14+
* $this->val = $val;
15+
* $this->next = $next;
16+
* }
17+
* }
18+
*/
19+
class Solution {
20+
21+
/**
22+
* @param ListNode $head
23+
* @return ListNode
24+
*/
25+
function deleteDuplicates($head) {
26+
if (!$head) {
27+
return null;
28+
}
29+
$cur = $head;
30+
while ($cur->next) {
31+
if ($cur->val == $cur->next->val) {
32+
$cur->next = $cur->next->next;
33+
} else {
34+
$cur = $cur->next;
35+
}
36+
}
37+
return $head;
38+
}
39+
}
40+
```
41+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /