合并两个有序链表
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def mergeTwoLists(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
liNo = ListNode(-1)
l3 = liNo
while l1 and l2 :
if l1.val>=l2.val:
l3.next = l2
l3 = l3.next
l2 = l2.next
else:
l3.next = l1
l3 = l3.next
l1 = l1.next
if l1:
l3.next = l1
else:
l3.next = l2
return liNo.next