1
class Solution {
2
public ListNode deleteDuplicates(ListNode head) {
3

4
if (head == null) {
5
return head;
6
}
7

8
ListNode result = head;
9

10
while (result != null) {
11
if (result.next == null) {
12
break;
13
}
14

15
if (result.val == result.next.val) {
16
result.next = result.next.next;
17
} else {
18
result = result.next;
19
}
20
}
21

22
return head;
23
}
24
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0