其他分享
首页 > 其他分享> > 剑指Offer 57

剑指Offer 57

作者:互联网

和为S的两个数字:

 1 # -*- coding:utf-8 -*-
 2 class Solution:
 3     def FindNumbersWithSum(self, array, tsum):
 4         n = len(array)
 5         i,j = 0,n-1
 6         while i<j:
 7             cur = array[i] + array[j]
 8             if cur == tsum:
 9                 return [array[i],array[j]]
10             if cur < tsum:
11                 i += 1
12             else:
13                 j -= 1
14         return []
15         # write code here

 

标签:FindNumbersWithSum,tsum,utf,Offer,57,array
来源: https://www.cnblogs.com/asenyang/p/11024609.html