EXY-SC-2925
第 51 题
数组
a 和 b 低位在前存储两个非负大整数,代码实现高精度加法,横线处应填写( )def add(a, b):
c = []
carry = 0
n = max(len(a), len(b))
for i in range(n):
sum_val = carry
if i < len(a):
sum_val += a[i]
if i < len(b):
sum_val += b[i]
c.append(sum_val % 10)
_______________
if carry != 0:
c.append(carry)
return c
语言:
Python
GESP真题
五级
2026.9
单选题号:
15
EXY-SC-2924
第 52 题
下面函数用迭代方式求解最大连续子段和。对于数组
[-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
语言:
Python
GESP真题
五级
2026.9
单选题号:
14
EXY-SC-2923
第 53 题
小杨要在一间教室安排尽可能多场活动,每场活动拥有开始时间
start 和结束时间 end 。使用贪心算法,正确的选择策略是( )class Activity:
def __init__(self, s, e):
self.start = s
self.end = e
语言:
Python
GESP真题
五级
2026.9
单选题号:
13
EXY-SC-2922
第 54 题
下面快速排序的划分函数以
a[right] 作为枢轴,把不大于枢轴的元素移动到数组左侧。横线处应填写 ( )。def partition(a, left, right):
pivot = a[right]
i = left - 1
for j in range(left, right):
if _______________:
i += 1
a[i], a[j] = a[j], a[i]
a[i + 1], a[right] = a[right], a[i + 1]
return i + 1
语言:
Python
GESP真题
五级
2026.9
单选题号:
12
EXY-SC-2921
第 55 题
下面是归并排序合并两个有序区间(升序排序)的片段。想要让排序算法保持稳定,横线处应当填写 ( )
while i <= mid and j <= right:
if _______________:
temp.append(a[i])
i += 1
else:
temp.append(a[j])
j += 1
语言:
Python
GESP真题
五级
2026.9
单选题号:
11
当前页显示 51 - 55
,共 1505 道单选题