{"id":22514015,"url":"https://github.com/emahtab/add-two-numbers","last_synced_at":"2026-02-04T13:36:03.080Z","repository":{"id":79525233,"uuid":"260585371","full_name":"eMahtab/add-two-numbers","owner":"eMahtab","description":"Add two linked lists nodes","archived":false,"fork":false,"pushed_at":"2020-05-02T00:31:30.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T03:26:23.720Z","etag":null,"topics":["leetcode","linked-list","problem-solving"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMahtab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-02T00:29:17.000Z","updated_at":"2020-05-02T00:32:08.000Z","dependencies_parsed_at":"2023-05-10T17:00:30.297Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/add-two-numbers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fadd-two-numbers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fadd-two-numbers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fadd-two-numbers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fadd-two-numbers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/add-two-numbers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245952504,"owners_count":20699495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["leetcode","linked-list","problem-solving"],"created_at":"2024-12-07T03:15:37.263Z","updated_at":"2026-02-04T13:36:03.015Z","avatar_url":"https://github.com/eMahtab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Add Two Numbers\n## https://leetcode.com/problems/add-two-numbers\n\nYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.\n\nYou may assume the two numbers do not contain any leading zero, except the number 0 itself.\n```\nExample:\n\nInput: (2 -\u003e 4 -\u003e 3) + (5 -\u003e 6 -\u003e 4)\nOutput: 7 -\u003e 0 -\u003e 8\nExplanation: 342 + 465 = 807.\n```\n\n# Implementation :\n```java\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode(int x) { val = x; }\n * }\n */\nclass Solution {\n    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {\n        ListNode dummyHead = new ListNode(0);\n        ListNode p = l1, q = l2, curr = dummyHead;\n        int carry = 0;\n        while (p != null || q != null) {\n            int x = (p != null) ? p.val : 0;\n            int y = (q != null) ? q.val : 0;\n            int sum = carry + x + y;\n            carry = sum / 10;\n            curr.next = new ListNode(sum % 10);\n            curr = curr.next;\n            if (p != null) \n                p = p.next;\n            if (q != null) \n                q = q.next;\n        }\n        \n        if (carry \u003e 0) {\n            curr.next = new ListNode(carry);\n        }\n    \n       return dummyHead.next;\n    }\n}\n```\n\n# References :\n1. https://www.youtube.com/watch?v=aM4Iv7eEr2o\n2. https://leetcode.com/articles/add-two-numbers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fadd-two-numbers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Fadd-two-numbers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fadd-two-numbers/lists"}