Mbpp/119

⚠️ Base 通过 / Plus 失败 Base: PASS Plus: FAIL
测试评估
指标结果
Base 测试PASS
Plus 测试FAIL
代码长度731 字符
模型生成的代码 (731 字符)
def search(arr):
    """
    Find the element that appears exactly once in a sorted array
    where every other element appears exactly twice.
    
    Args:
        arr: List[int] - sorted array with exactly one single element
    Returns:
        int - the single element
    """
    lo, hi = 0, len(arr) - 1
    while lo < hi:
        mid = lo + (hi - lo) // 2
        # Ensure mid is even so we can compare mid and mid+1 as a pair
        if mid % 2 == 1:
            mid -= 1
        # If pair is intact, single element must be to the right
        if arr[mid] == arr[mid + 1]:
            lo = mid + 2
        else:
            # Pair broken, single element is at or to the left of mid
            hi = mid
    return arr[lo]
Base 失败测试用例
  • 无失败测试
Plus 失败测试用例
  • [[]]