Python, difference between submit and custom-input options for the same input


  • 0
    G
    class NumArray(object):
        nums = []
        def __init__(self, nums):
            for i in nums:
                self.nums.append(i)
            
    
        def sumRange(self, i, j):
            sum = 0
            print sum
            for k in range(i, j+1):
                sum = sum + self.nums[k]
                
            return sum
    

    If i submit the above code, I am getting error for the following input.
    ["NumArray","sumRange"]
    [[[-1]],[0,0]]

    However, if I use "custom input" option, I am getting the correct answer. Please help me see what I am missing.


Log in to reply
 

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