Leetcode link: https://leetcode.com/problems/add-two-numbers/submissions/
Given 2 non-empty singly linked list which represent numbers stored in reverse order, with each node representing a single digit, add the 2 numbers together and return a new linked list representing the result.
The 2 linked lists may not be of the same length.
- Time complexity:
O(n + m)where
nis the length of first linked list and
mis the length of the second linked list.
- Space complexity:
O(n + m)for creation of new linked list