Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Linked lists

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Linked lists

Add Two Numbers

intermediatelayer B9 · Linked lists5 tests

Two non-negative integers are stored as linked lists with one digit per node, least significant digit first. Add them and return the sum in the same format.

  • So [2,4,3] means 342 and [5,6,4] means 465; the sum 807 is [7,0,8]
  • The lists may have different lengths
  • A final carry needs an extra node
  • Do not join the digits into a JavaScript number — assume the values overflow

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen