Add Two Numbers - LeetCode 2 Solution Explained

preview_player
Показать описание

*As an Amazon affiliate, commissions are earned on purchases.
#shorts #leetcode #programming #coding
Рекомендации по теме
Комментарии
Автор

I want to clarify that at 0:31, when I say you get 807, I mean that you'll get this result after summing up both numbers. That's because after processing the first linked list, you get the original input 342. After processing the second linked list, you get 465. Using the normal addition operator, you get 807. You can then process 807 using a combination of modulo and integer division operations to store each digit in a new linked list in reverse order.

nextrie
Автор

This is O(n^2) solution, assuming you calculate both numbers together. There is O(n) solution available.

yahyaabdulmajeed
visit shbcf.ru