IT_World
[leetcode] 83. Remove Duplicates from Sorted List 본문
Coding test/programmers - single
[leetcode] 83. Remove Duplicates from Sorted List
engine 2022. 4. 3. 23:58class Solution:
def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:
dta = ListNode(0)
dta.next = head
dataset = set()
while head and head.next:
dataset.add(head.val)
while head.next and head.next.val in dataset :
head.next = head.next.next
head = head.next
return dta.next
'Coding test > programmers - single' 카테고리의 다른 글
[leetcode] 62. Unique Paths (0) | 2022.04.04 |
---|---|
[leetcode] 94. Binary Tree Inorder Traversal (0) | 2022.04.04 |
[leetcode] 88. Merge Sorted Array (0) | 2022.04.03 |
[leetcode] 70. Climbing Stairs (0) | 2022.04.02 |
[leetcode] 39. Combination Sum (0) | 2022.04.01 |
Comments