# 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
"""
cur1 = l1
cur2 = l2
dummyHead = ListNode(0)
pre = dummyHead
while cur1 and cur2:
if cur1.val <= cur2.val:
pre.next = cur1
pre = pre.next
cur1 = cur1.next
else:
pre.next=cur2
pre = pre.next
cur2 = cur2.next
if cur1:
pre.next = cur1
if cur2:
pre.next = cur2
return dummyHead.next