ADD TWO NUMBERS | PYTHON SOLUTION | LEETCODE # 2

preview_player
Показать описание
In this video, we'll be solving Leetcode Problem #2: Add Two Numbers. This is a relatively straightforward problem where we want to add two linked lists together and return their result.

This problem follows the same solution template as the problem for adding two strings together except there is a little bit more intricacy in that we are dealing with LinkedLists here.
Рекомендации по теме
Комментарии
Автор

Would the space complexity be O(max(N, M) + 1)? If l1 has 5 nodes and l2 has 6 nodes, you would only create 6 nodes, not 11. You might have a carry node at the end so you can throw the plus one on the end.

patrickcunningham