LeetCode-Feedback / LeetCode-Feedback

677 stars 335 forks source link

Missing Test Case - 2. Add Two Numbers #24312

Closed Sanket312001 closed 2 months ago

Sanket312001 commented 2 months ago

LeetCode Username

sanket3101

Problem Number, Title, and Link

https://leetcode.com/problems/add-two-numbers/

Bug Category

Problem examples

Bug Description

I have added a test case when one array has one less element

Language Used for Code

Python/Python3

Code used for Submit/Run operation

Definition for singly-linked list.
class ListNode:
    def __init__(self, val=0, next=None):
         self.val = val
         self.next = next
class Solution:
    def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
        dummy = ListNode()
        tail = dummy
        total = carry = 0

        while l1 or l2 or carry:
            total = carry
            if l1: 
                total += l1.val
                l1 = l1.next
            if l2:
                total +=l2.val
                l2 = l2.next

            num = total % 10
            carry = total // 10
            dummy.next = ListNode(num)
            dummy = dummy.next

        return tail.next

Expected behavior

There is a test case missing in which there are two lists one with three arrays and one with two arrays. So we have added that test case.

Screenshots

image

Additional context

No response

exalate-issue-sync[bot] commented 2 months ago

LeetCode Support commented: Thank you for your contribution. It appears that the test case is mentioned but not explicitly provided. Could you please include the specific test input values that you believe should be tested?

Looking forward to your response.

LeetCode Support Team.