Python 运行时找不到代码中定义的函数

Python 运行时找不到代码中定义的函数,python,Python,处理leetcode max子阵列问题时,我无法定义其他功能 下面的代码中是否存在明显的打字错误,导致无法定义函数 此外,为什么它们在函数定义中包含每个参数的类型?我在其他包装中没有看到,比如熊猫 class Solution: def maxSubArraySum(self, nums:List[int], low:int, high:int) -> int: return 0 def maxSubArray(self, nums: List[in

处理leetcode max子阵列问题时,我无法定义其他功能

下面的代码中是否存在明显的打字错误,导致无法定义函数

此外,为什么它们在函数定义中包含每个参数的类型?我在其他包装中没有看到,比如熊猫

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))
在leetcode IDE中运行此命令将返回:

NameError: maxSubArraySum is not defined

MaxSubraySum是解决方案类的方法。您必须从当前实例调用它。self.maxsubararaysumms,0,lennums-1

在leetcode和此类竞争性编程平台中,需要使用给定的函数/类定义找到解决方案,但不能更改输入或输出结构。数据类型在函数定义中给出,以便程序员更好地理解预期的输入/输出