Skip to content

Commit

Permalink
having a tech seminar with Naofu
Browse files Browse the repository at this point in the history
  • Loading branch information
Meng Wei authored and Meng Wei committed Jan 12, 2018
1 parent 714a4cb commit ebe67dd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 24-swap-nodes-in-pairs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None

class Solution(object):
def swapPairs(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
dummy = ListNode(0)
dummy.next = head
ret = dummy
while dummy.next and dummy.next.next:
curr = dummy.next
after = curr.next
temp = after.next
dummy.next = after
after.next = curr
curr.next = temp

dummy = dummy.next.next
return ret.next
19 changes: 19 additions & 0 deletions 83-remove-duplicateds-from-sorted-list
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None

class Solution(object):
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
ret = head
while head and head.next:
if head.next.val == head.val:
head.next = head.next.next
else:
head = head.next
return ret

0 comments on commit ebe67dd

Please sign in to comment.