MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / addTwoNumbers

Function addTwoNumbers

javascript/0002-add-two-numbers.js:8–17  ·  view source on GitHub ↗
(l1, l2)

Source from the content-addressed store, hash-verified

6 * @return {ListNode}
7 */
8var addTwoNumbers = function (l1, l2) {
9 let sentinel = (tail = new ListNode());
10
11 return add(
12 l1,
13 l2,
14 tail,
15 sentinel,
16 ); /* Time O(MAX(N, M)) | Space O(MAX(N, M)) */
17};
18
19const add = (l1, l2, tail, sentinel, carry = 0) => {
20 const isBaseCase = !(l1 || l2 || carry);

Callers

nothing calls this directly

Calls 1

addFunction · 0.70

Tested by

no test coverage detected