Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Add two numbers stored in lists

    Add two numbers stored in lists

    Mediumlinked listmath

    Each list represents a non-negative number with its digits stored in reverse (ones digit first), one digit per node. Add the two numbers and return the sum in the same form.

    Example 1

    Input:  a = [2,4,3], b = [5,6,4]
    Output: [7,0,8]

    342 + 465 = 807.

    Example 2

    Input:  a = [9,9,9,9], b = [9,9]
    Output: [8,9,0,0,1]

    Constraints

    • 1 ≤ nodes in each list ≤ 100
    • 0 ≤ Node.val ≤ 9
    • No leading zeros except the number 0 itself

    Submit checks your solution against 9 tests, including hidden ones.

    // Provided by the judge: keep these definitions
    class ListNode {
      constructor(val = 0, next = null) {
        this.val = val
        this.next = next
      }
    }
    
    /**
     * @param {ListNode|null} a
     * @param {ListNode|null} b
     * @return {ListNode|null}
     */
    function addTwoNumbers(a, b) {
      
    }
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.