Construct Binary Tree from Inorder and Postorder Traversal @ LeetCode (Python)
Container With Most Water @ LeetCode (Python)

Remove Duplicates from Sorted List II @ LeetCode (Python)

kitt posted @ 2014年4月14日 20:06 in LeetCode , 2272 阅读
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    # @param head, a ListNode
    # @return a ListNode
    def deleteDuplicates(self, head):
        if head == None: return None
        dummy = ListNode(10**10)
        dummy.next, head = head, dummy # add a dummy node
        pprev, prev, curr, dupFlag = head, head.next, head.next.next, False
        while True:
            if dupFlag == True:
                if curr == None:
                    pprev.next = None
                    break
                if prev.val != curr.val:
                    pprev.next, prev, dupFlag = curr, curr, False
            else:
                if curr == None: break
                if prev.val == curr.val: 
                    dupFlag = True
                else:
                    pprev, prev = pprev.next, prev.next
            curr = curr.next
        return head.next # remove dummy
Avatar_small
housekeeping service 说:
2021年9月01日 03:59

The task of being a parent involves coping with lots associated with mess. Moms (particularly housewives) tend to be mostly in the center of messy work. Sometimes they're found wiping their own sticky fingers along with other times they're sorting via mental hardship. For all of them, the heart and soul of calmness for some time tends to become painfully incredibly elusive. For all of them, standard home cleaning services tend to be nothing under a great asset. The moods associated with moms happen to be observed to alter for the greater, once their own household cleansing work accomplishes.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter