Answer: Square OA Question 2024 August | Linked List | on-campus

Answer · Posted Jun 2026

Solution: Add Two Numbers — Elementary Math Simulation Approach We simulate grade school addition digit by digit, managing a carry. Since the digits are already in reverse order, we simply traverse both lists from head to tail: At each step, sum the current digits from both lists (or 0 if a list is exhausted) plus the carry. The new digit is sum % 10. The new carry is sum / 10. Create a new node with the digit and link ...

The full answer & interview discussion are available to premium members.

Log in Create a free account