Mbpp/793

✅ 完美通过 Base: PASS Plus: PASS
测试评估
指标结果
Base 测试PASS
Plus 测试PASS
代码长度463 字符
模型生成的代码 (463 字符)
def last(arr, x):
    """
    Find the last position of an element in a sorted array.
    Returns the highest index where x is found, or -1 if not present.
    """
    lo, hi = 0, len(arr) - 1
    result = -1
    while lo <= hi:
        mid = (lo + hi) // 2
        if arr[mid] == x:
            result = mid
            lo = mid + 1  # look to the right
        elif arr[mid] < x:
            lo = mid + 1
        else:
            hi = mid - 1
    return result
Base 失败测试用例
  • 无失败测试
Plus 失败测试用例
  • 无失败测试