测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | FAIL |
| 代码长度 | 607 字符 |
模型生成的代码 (607 字符)
def max_sub_array_sum(arr, n):
"""
Find the sum of the largest contiguous sublist in the first n elements of arr.
Uses Kadane's algorithm.
"""
if n <= 0 or not arr:
return 0
# We only consider the first n elements, but n can be larger than len(arr)
# So we take min(n, len(arr)) to avoid index errors.
length = min(n, len(arr))
max_ending_here = arr[0]
max_so_far = arr[0]
for i in range(1, length):
max_ending_here = max(arr[i], max_ending_here + arr[i])
max_so_far = max(max_so_far, max_ending_here)
return max_so_far
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
[[-10, -5, -3, -2, -1], 5]