328. Odd Even Linked List

328. Odd Even Linked List
这么简单的题竟然卡了半天,原因是最后merge的时候写成了p1.next=haed.next,啥了吧head.next已经不是第二个了。
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def oddEvenList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head == None or head.next == None or head.next.next == None:
return head
p1 = head
p2 = p2head = head.next
while p2 and p2.next:
p1.next = p2.next
p1 = p1.next
p2.next = p1.next
p2 = p2.next
p1.next = p2head
return head