FastPrepAdd Forward Linked-List Numbers Using Recursion
Problems/Add Forward Linked-List Numbers Using Recursion

Add Forward Linked-List Numbers Using Recursion

PeopleStrong logoPeopleStrong● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a PeopleStrong phone screen. The candidate linked a reference that asks for adding digit lists, written in forward order, using recursion, with no extra leading zeros in the output. This version keeps that variant. We chose that the input is kept as it is, plus the function interface and the limits. Our version is about 95% the same as the reported question.

Two nonnegative decimal integers are stored in singly linked lists first and second, with the most significant digit first. Each node contains one digit. Use recursion to add the digits and return a new linked list representing their sum in the same forward order.

For this exercise, assume both inputs are nonempty and may contain leading zeros. Normalize the output by removing leading zeros, except that zero itself is represented by one node containing 0. Preserve both input lists. Lists are serialized as arrays in head-to-tail order.

Function

addListNumbers(first: ListNode, second: ListNode) → ListNode

Examples

Example 1

first = [7,2,4,3]second = [5,6,4]return = [7,8,0,7]
first
7243
second
564
return
7807

The lists represent 7243 and 564; their sum is 7807.

Example 2

first = [0,0,9]second = [0,1]return = [1,0]
first
009
second
01
return
10

Leading zeros do not change 9 + 1 = 10. The output contains no extra leading zeros.

Constraints

  • For this exercise, assume each list has 1 to 1000 nodes.
  • Every node value is an integer digit from 0 through 9.
  • Both lists are finite and acyclic.

More PeopleStrong Phone Screen questions

  • Reverse Linked-List Nodes in Groups of KOA · PHONE SCREEN · Seen Mar 2026
  • Level of the Minimum-Sum SubtreePHONE SCREEN · Seen Jan 2026
  • Ceiling Value in a Sorted ArrayPHONE SCREEN · Seen Sep 2025
  • Maximum Employee Salary for a CompanyPHONE SCREEN · Seen Sep 2025
  • Valid ParenthesesPHONE SCREEN · Seen Sep 2025
  • Number of ProvincesPHONE SCREEN · Seen May 2025
  • Shortest Subarray with an Exact Target SumPHONE SCREEN · Seen May 2025
  • Running Median of a StreamPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2021
  • Build an Expression Tree from PostfixPHONE SCREEN · Seen Oct 2021
  • Maximum Score from Deleting Neighboring ValuesPHONE SCREEN · Seen Oct 2021

Similar questions at other companies

  • Add Two Numbers IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Subtract Forward-Order Linked-List NumbersMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Basic Calculator IISnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Simplify a Nested Variable ExpressionGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Turn a BST Into a Sorted Doubly Linked ListAdobe · PHONE SCREENAdobe interview questions
  • Min StackCapital One · PHONE SCREEN · ONSITE INTERVIEWCapital One interview questions
  • Evaluate Reverse Polish NotationCoalition · PHONE SCREEN
  • Evaluate Arithmetic with Operator PrecedenceRoblox · PHONE SCREENRoblox interview questions
  • Simplify a Formula with Known and Unknown VariablesBetter.com · PHONE SCREEN
  • Evaluate Parenthesized Addition and SubtractionAtlassian · PHONE SCREENAtlassian interview questions

Interview reports that mention this question

  • PeopleStrong SDE OA and Interview Questions: 12 Experiences
All PeopleStrong interview questionsSee PeopleStrong hiring insights
Saved
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode addListNumbers(ListNode first, ListNode second) {
        // Write your solution here.
    }
}
Checking account…