Coding Round 1
Mid-Level
programming
LeetCode #2 - Add Two Numbers
Given two non-empty linked lists representing two non-negative integers, where each node contains a single digit. The digits are stored in reverse order, meaning that the 1's digit is at the head of the linked list. You need to add the two numbers and return it as a linked list.
Function Signature:
Example 1:
Input: l1 = [2,4,3], l2 = [5,6,4]
Output: [7,0,8]
Explanation: 342 + 465 = 807.
Example 2:
Input: l1 = [0], l2 = [0]
Output: [0]
Constraints: 1 <= len(l1), len(l2) <= 100, 0 <= Node.val <= 9.
Function Signature:
def addTwoNumbers(l1: ListNode, l2: ListNode) -> ListNode:Example 1:
Input: l1 = [2,4,3], l2 = [5,6,4]
Output: [7,0,8]
Explanation: 342 + 465 = 807.
Example 2:
Input: l1 = [0], l2 = [0]
Output: [0]
Constraints: 1 <= len(l1), len(l2) <= 100, 0 <= Node.val <= 9.
Suggested Answer