Skip to content

Commit e72fa53

Browse files
committed
commit
1 parent 49e0c23 commit e72fa53

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* public class ListNode {
4+
* int val;
5+
* ListNode next;
6+
* ListNode() {}
7+
* ListNode(int val) { this.val = val; }
8+
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
9+
* }
10+
*/
11+
class Solution {
12+
public ListNode deleteDuplicates(ListNode head) {
13+
ListNode curr_node = head;
14+
15+
while (curr_node != null && curr_node.next != null) {
16+
if (curr_node.val == curr_node.next.val)
17+
curr_node.next = curr_node.next.next;
18+
else
19+
curr_node = curr_node.next;
20+
}
21+
22+
return head;
23+
}
24+
}

0 commit comments

Comments
 (0)