File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 29
29
| 66 | [ Plus One] ( https://leetcode.com/problems/plus-one ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/PlusOne.java ) |
30
30
| 67 | [ Add Binary] ( https://leetcode.com/problems/add-binary ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/AddBinary.java ) |
31
31
| 69 | [ Sqrt(x)] ( https://leetcode.com/problems/sqrtx ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/Sqrtx.java ) |
32
- | 70 | [ Climbing Stairs] ( https://leetcode.com/problems/climbing-stairs ) | Easy | |
32
+ | 70 | [ Climbing Stairs] ( https://leetcode.com/problems/climbing-stairs ) | Easy | [ ![ Java ] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/ClimbingStairs.java ) |
33
33
| 83 | [ Remove Duplicates from Sorted List] ( https://leetcode.com/problems/remove-duplicates-from-sorted-list ) | Easy | |
34
34
| 88 | [ Merge Sorted Array] ( https://leetcode.com/problems/merge-sorted-array ) | Easy | |
35
35
| 100 | [ Same Tree] ( https://leetcode.com/problems/same-tree ) | Easy | |
Original file line number Diff line number Diff line change
1
+ public class RemoveDuplicatesFromSortedList {
2
+ public static class ListNode {
3
+ int val ;
4
+ ListNode next ;
5
+
6
+ ListNode () {
7
+ }
8
+
9
+ ListNode (int val ) {
10
+ this .val = val ;
11
+ }
12
+
13
+ ListNode (int val , ListNode next ) {
14
+ this .val = val ;
15
+ this .next = next ;
16
+ }
17
+ }
18
+
19
+ public ListNode deleteDuplicates (ListNode head ) {
20
+ ListNode current = head ;
21
+ while (current != null ) {
22
+ if (current .next != null && current .next .val == current .val ) {
23
+ current .next = current .next .next ;
24
+ } else {
25
+ current = current .next ;
26
+ }
27
+ }
28
+ return head ;
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments