题目:
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
# coding:gbk
L = [2, 7, 11, 15]
target = 9
for i_1 in range(len(L)):
for i_2 in range(len(L)):
M = L[i_1] + L[i_2]
if M == target:
if i_1 < i_2: #假设不考虑同一元素的情况(target为偶数,无=),
print([i_1, i_2])