Add Two Numbers
Updated
Problem statement
Given two linked lists l1 and l2 that each store a nonnegative integer, return the sum of the two numbers as a linked list.
Each node holds one digit, and the digits are in reverse order, so the first node holds the ones digit. Return the sum in the same format. Neither input has leading zeroes, except the number zero itself.
Function
addTwoNumbers(l1: ListNode, l2: ListNode) → ListNodeExamples
Example 1
l1 = [2,4,3]l2 = [5,6,4]return = [7,0,8]Read backward, the lists are 342 and 465. Their sum is 807, and its digits in reverse order give the output list.
Example 2
l1 = [9,9,9]l2 = [1]return = [0,0,0,1]Adding from the front, each position sums to ten, so each result digit is zero and a carry moves on. The carry left after the last position becomes a new node at the end.
Constraints
- Each list has between
1and100nodes. - Every node value is between
0and9.
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Subtract Forward-Order Linked-List NumbersMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Add Two Numbers Stored in Reversed ListsExpedia · ONSITE INTERVIEWExpedia interview questions
- Add Numbers Stored in Four-Digit ChunksZipRecruiter · ONSITE INTERVIEWZipRecruiter interview questions
- Add Forward Linked-List Numbers Using RecursionPeopleStrong · PHONE SCREENPeopleStrong interview questions
- Add Two Numbers Stored as Linked ListsCapital One · ONSITE INTERVIEWCapital One interview questions
- Add NumbersCisco · OACisco interview questions
- Binary Linked List to DecimalJP Morgan Chase · OAJP Morgan Chase interview questions
- LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
- Integers With Multiple Sum of Two CubesCharta Health · PHONE SCREEN · ONSITE INTERVIEWCharta Health interview questions
Interview reports that mention this question
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)