Skip to content

Commit 1d62120

Browse files
committedJun 20, 2021
solves remove linked listnode in python
1 parent ee603bf commit 1d62120

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed
 

Diff for: ‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![problems-solved](https://img.shields.io/badge/Problems%20Solved-107/571-1f425f.svg)
44
![problems-solved-java](https://img.shields.io/badge/Java-107/1571-1abc9c.svg)
5-
![problems-solved-python](https://img.shields.io/badge/Python-27/1571-1abc9c.svg)
5+
![problems-solved-python](https://img.shields.io/badge/Python-28/1571-1abc9c.svg)
66
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
77

88
## Problems
@@ -26,7 +26,7 @@
2626
| 67 | [Add Binary](https://leetcode.com/problems/add-binary) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/AddBinary.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](python/add_binary.py) |
2727
| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/Sqrtx.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](python/sqrt.py) |
2828
| 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/ClimbingStairs.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](python/climbing_stairs.py) |
29-
| 83 | [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/RemoveDuplicatesFromSortedList.java) |
29+
| 83 | [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/RemoveDuplicatesFromSortedList.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](python/remove_duplicates_from_linked_list.py) |
3030
| 88 | [Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/MergeSortedArray.java) |
3131
| 100 | [Same Tree](https://leetcode.com/problems/same-tree) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/SameTree.java) |
3232
| 101 | [Symmetric Tree](https://leetcode.com/problems/symmetric-tree) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/SymmetricTree.java) |

Diff for: ‎python/remove_duplicates_from_linked_list.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class ListNode:
2+
def __init__(self, val=0, next=None):
3+
self.val = val
4+
self.next = next
5+
6+
7+
def deleteDuplicates(head: ListNode) -> ListNode:
8+
if head is None:
9+
return None
10+
current = head
11+
while current is not None:
12+
if current.val == current.next.val:
13+
current.next = current.next.next
14+
else:
15+
current = current.next
16+
return head

0 commit comments

Comments
 (0)
Please sign in to comment.