[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/feixiangcode/algorithm/master/Week_01/id_118/leetcode_21_118.java [Back]  [Original]

/**
 *
 * https://leetcode-cn.com/problems/merge-two-sorted-lists/submissions/
 *
 * 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) {

        // 1. nullnull
        if(l1==null || l2==null ){
            return l1 == null ? l2 : l1;
        }

        // 2. 
        // - 0
        // - 
        ListNode head = new ListNode(0);
        ListNode current = head;

        // 3. 
        //  - 
        while(l1!=null && l2!=null){
            if(l1.val

Web Proxy Viewer  |  New URL  |  Original Page