题解 | #两数之和#
两数之和
http://www.nowcoder.com/practice/20ef0972485e41019e39543e8e895b7f
a = eval(input()) s,sum1 = a[0],a[1] for i in range(len(s)): if sum1 - s[i] in s[i+1:]: j = int(s[i+1:].index(sum1-s[i])+2+i) print("["+str(i+1)+","+str(j)+"]")
两数之和
http://www.nowcoder.com/practice/20ef0972485e41019e39543e8e895b7f
a = eval(input()) s,sum1 = a[0],a[1] for i in range(len(s)): if sum1 - s[i] in s[i+1:]: j = int(s[i+1:].index(sum1-s[i])+2+i) print("["+str(i+1)+","+str(j)+"]")
相关推荐