why it is wrong?


  • 0
    H

    i test it on my own IDE can run good, why it is an empty array in leetCode???

    var addTwoNumbers = function(l1, l2) {
        if (l1.length !== l2.length) {
            return false;
        }
        let listNode = [];
        let up = false;
        for (let i = 0; i < l1.length; i++) {
            if (up) {
                listNode.push(l1[i] + l2[i] + 1) ;
            } else {
                listNode.push(l1[i] + l2[i]);
            }
            if (listNode[i] >= 10) {
                listNode[i] -= 10;
                up = true;
            }
            
        }
        return listNode;
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.