When I use javascript but input not is tow arr


  • 0
    T

    var addTwoNumbers = function(l1, l2) {
    var newArr = []
    var nextMore = 0
    console.log(l1)
    for (var i=0; i<l1.length; i++) {
    var sum = l1[i] + l2[i]
    if (sum >= 10) {
    console.log(nextMore)
    newArr[i] = +(sum+'').slice(1, 2) + nextMore
    nextMore = 1
    } else {
    newArr[i] = sum + nextMore
    nextMore = 0
    }
    }
    return newArr
    };


Log in to reply
 

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