https://leetcode-cn.com/problems/merge-two-sorted-lists/
- 简单题,有限几个变量搞定
```java
public static ListNode mergeTwoLists(ListNode l1, ListNode l2) {
if (l1 == null) return l2;
if (l2 == null) return l1;
ListNode head;
if (l1.val <= l2.val) {
} else {head = l1;l1 = l1.next;
} ListNode cur = head; while (l1 != null && l2!= null) {head = l2;l2 = l2.next;
} if (l1 == null) {if (l1.val <= l2.val) {cur = cur.next = l1;l1 = l1.next;} else {cur = cur.next = l2;l2 = l2.next;}
} if (l2 == null) {cur.next = l2;
} return head; }cur.next = l1;
public static class ListNode { int val; ListNode next; ListNode() {} ListNode(int val) { this.val = val; } ListNode(int val, ListNode next) { this.val = val; this.next = next; } }
```
