思路:
// @Title: 训练计划 IV (训练计划 IV)
// @Author: qisiii
// @Date: 2022-02-20 21:07:47
// @Runtime: 0 ms
// @Memory: 41.3 MB
// @comment:
// @flag:
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
if(l1==null){
return l2;
}
if(l2==null){
return l1;
}
ListNode temp;
if(l1.val<l2.val){
temp=l1;
l1=l1.next;
}else{
temp=l2;
l2=l2.next;
}
temp.next=mergeTwoLists(l1,l2);
return temp;
}
}