| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + /** | ||
| 2 | + * Definition for a singly-linked list. | ||
| 3 | + * class ListNode { | ||
| 4 | + * public $val = 0; | ||
| 5 | + * public $next = null; | ||
| 6 | + * function __construct($val) { $this->val = $val; } | ||
| 7 | + * } | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | + class Solution { | ||
| 11 | + public function deleteDuplicates($headNode) { | ||
| 12 | + $current = $headNode; | ||
| 13 | + while($current->next !=null){ | ||
| 14 | + if($current->val == $current->next->val ){ | ||
| 15 | + $current->next = $current->next->next; | ||
| 16 | + }else{ | ||
| 17 | + $current = $current->next; | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | + return $headNode; | ||
| 21 | + } | ||
| 22 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments