Movatterモバイル変換


[0]ホーム

URL:


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

Commit4e9bb36

Browse files
authored
Merge pull requestneetcode-gh#1418 from imevanc/Create-83-Remove-Duplicates-From-Sorted-List
Create: 83-Remove-Duplicates-From-Sorted-List.js
2 parentsaa783df +c4b5b0e commit4e9bb36

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* https://leetcode.com/problems/remove-duplicates-from-sorted-list/
3+
* Definition for singly-linked list.
4+
* function ListNode(val, next) {
5+
* this.val = (val===undefined ? 0 : val)
6+
* this.next = (next===undefined ? null : next)
7+
* }
8+
*/
9+
/**
10+
*@param {ListNode} head
11+
*@return {ListNode}
12+
*/
13+
vardeleteDuplicates=function(head){
14+
letcur=head;
15+
while(cur!=null&&cur.next!=null){
16+
if(cur.next.val===cur.val){
17+
cur.next=cur.next.next;
18+
}else{
19+
cur=cur.next;
20+
}
21+
}
22+
returnhead;
23+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp