Add Two Integers Represented by Linked Lists

Given the head pointers of two linked lists where each linked list represents an integer number (each node is a digit), add them and return the resulting number in a linked list.

Statement

We are given the head pointers of two linked lists, each linked list represents an integer number (each node is a digit). Add them and return the resulting linked list (i.e., sum).

Here, the first node in a list represents the least significant digit.

Example

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.