Solution to "Remove Duplicates from Sorted List" on Leetcode.
1# Definition for singly-linked list.
2# class ListNode:
3# def __init__(self, val=0, next=None):
4# self.val = val
5# self.next = next
6class Solution:
7 def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:
8 result = head
9 cur = head
10 while cur is not None:
11 if cur.next is not None:
12 if cur.next.val == cur.val:
13 cur.next = cur.next.next
14 else:
15 cur = cur.next
16 else:
17 cur = cur.next
18
19 return result
Solution to "Count Number of Texts" question on Leetcode.
Solution to "Second Minimum Node In a Binary Tree" on Leetcode.