Why my Python code sucessed in IDE but failed on submit?

  • 0
    class Solution:
        # @return a tuple, (index1, index2)
        def twoSum(self, num, target):
            set1 = set()
            set2 = set()
            for i in num:
                if i == target:
                    return 0, i
                set2.add(target -i)
            res = set1 & set2
            if len(res) == 1:
                i = res.pop()
                return i, i
            return tuple(res)

    here is what I got

    Input:	[0,4,3,0], 0
    Output:	0, 0
    Expected:	1, 4

    bu in IDE function retruns (0,0) with Input: [0,4,3,0], 0

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.