标签:nbsp number describe 知识 with pre utf-8 等于 item
对应每个测试案例,输出两个数,小的先输出。
思路:
两头匹配,最先找到的注定乘机最小:
# -*- coding:utf-8 -*- class Solution: def FindNumbersWithSum(self, array, tsum): # write code here low,high = 0,len(array)-1 while low< high: if array[low]+array[high] > tsum: high -=1 elif array[low]+array[high] < tsum: low +=1 else: return [array[low],array[high]] return []
剑指offer-和为S的两个数字-知识迁移能力-python
标签:nbsp number describe 知识 with pre utf-8 等于 item
原文地址:https://www.cnblogs.com/ansang/p/12071659.html