KOUSHIK THOTA’s Post

🚀 Day 23 / 100 | Add Two Numbers -Approach : O(n) - Traverse both linked lists simultaneously. - Maintain a carry variable to handle sums that are greater than or equal to 10. - Use a ans node to simplify the construction of the result list. - At each step, compute the sum as: sum = val1 + val2 + carry. - Update the carry as carry = sum / 10 and store sum % 10 in a new node. - Continue this process until both lists and the carry are exhausted. - Finally, return ans.next. #100DaysOfCode #LeetCode #Java #DSA #LinkedList #ProblemSolving

  • text

To view or add a comment, sign in

Explore content categories