# Python代码

class Solution:
"""
@param numbers : An array of Integer
@param target : target = numbers[index1] + numbers[index2]
@return : [index1 + 1, index2 + 1] (index1 < index2)
"""
def twoSum(self, numbers, target):
ret = []
for i in range(len(numbers)):
for j in range(i+1,len(numbers)):
if numbers[i] + numbers[j] == target:
ret.append(i+1)
ret.append(j+1)

return ret


GitHub源码--Python

# C++代码

class Solution {
public:
/*
* @param numbers : An array of Integer
* @param target : target = numbers[index1] + numbers[index2]
* @return : [index1+1, index2+1] (index1 < index2)
*/
vector<int> twoSum(vector<int> &nums, int target) {
if(nums.empty())
{
return vector<int>();
}//if

int len = nums.size();
vector<int> ret;
for(int i=0; i<len; ++i)
{
for(int j=i+1; j<len; ++j)
{
if(nums[i] + nums[j] == target)
{
ret.push_back(i+1);
ret.push_back(j+1);
return ret;
}//if
}//for
}//for

return vector<int>();
}
};

GitHub源码 -- C++

#### <LeetCode> 题56：两数之和

2016-07-19 09:53:10

#### LintCode 56 两数之和

2017-04-30 09:18:28

#### lintcode-两数之和-56

2015-09-15 00:29:13

#### LintCode 两数之和

2015-10-04 15:17:28

#### lintcode之两数之和

2016-04-21 20:56:01

#### LintCode两数之和，三数之和，四数之和

2017-09-20 11:14:33

#### Lintcode 两数之和

2015-03-20 16:18:16

#### 1.无序数组中找出两个数使其和等于给定值

2014-09-25 19:23:47

#### 给一个整数数组，找到两个数使得他们的和等于一个给定的数 target(容易)

2017-07-24 17:55:20

#### 关于一个数组中两个数的和等于给定数的问题

2015-07-14 21:30:20