-1

working through the leetcode max subarray problem, I'm unable to define other fuctions.

Is there an obvious typo in the code below that prevents the functions from being defined?

Additionally, why do they include types for each argument in the function definitions? I haven't seen that in other packages, pandas for instance.

class Solution:

    def maxSubArraySum(self, nums:List[int], low:int, high:int)  -> int:

        return 0

    def maxSubArray(self, nums: List[int]) -> int:

        return maxSubArraySum(nums, 0, (len(nums)-1))

Running this in the leetcode IDE returns:

NameError: maxSubArraySum is not defined
Hugh_Kelley
  • 988
  • 1
  • 9
  • 23
  • 2
    In leetcode and such competitive programming platforms it is required to come to a solution with the given function/class definition, one cannot change the input or output structure. And the datatype is given in function definition so that programmer has better understanding of expected inputs/output – psn1997 Sep 25 '19 at 14:04

1 Answers1

1

maxSubArraySum is method of the Solution's class. You have to call it from the current instance. self.maxSubArraySum(nums, 0, (len(nums)-1))