【发布时间】:2018-03-09 11:44:18
【问题描述】:
这是一个关于 LeetCode 的练习。我得到了一个例外
UnboundLocalError 在第 15 行。
为什么?以及如何解决?
类解决方案(对象): def twoSum(self, nums, target): """ :type nums: 列表[int] :类型目标:int :rtype: 列表[int] """ self.nums = [] self.target = int 对于我在范围内(len(nums)): 对于范围内的 j (i + 1, len(nums)): 如果 nums[i] + nums[j] == 目标: 一个 = [] 返回 a[i, j]【问题讨论】:
-
请附上问题陈述或在此类帖子中添加问题链接。
标签: python arrays algorithm sorting