1条回答 默认 最新
- chuifengde 2021-11-13 20:35关注
def find_mm(L): global depth depth += 1 print("Into", depth, L) if len(L) == 1: depth -= 1 print("return to ", depth) return L[0], L[0] if len(L) == 2: depth -= 1 print("return to ", depth) return min(L[0], L[1]), max(L[0], L[1]) min1, max1 = find_mm(L[0:len(L)//2]) min2, max2 = find_mm(L[len(L)//2:len(L)]) depth -= 1 print("return to", depth) return min(min1, min2), max(max1, max2) depth = 0 L = [9, 3, 1, 5,2, 0, 7, 8, 10, 2] print(find_mm(L))
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报