第42351题 单选题
下面函数用迭代方式求解最大连续子段和。对于数组 [-2, 3, -1, 5, -6, 2],函数返回结果是 ( )
def maxSubArray(a):
    best = a[0]
    current = a[0]
    for i in range(1, len(a)):
        current = max(a[i], current + a[i])
        best = max(best, current)
    return best
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析