您的位置:首页 > 其它

Leetcode 1 Two Sum

2017-06-10 14:22 441 查看

Leetcode 1 Two Sum

#include <vector>
using namespace std;
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> result;
int length = nums.size();
for (int i = 0; i < length; i++)
{
for (int j = i + 1; j < length; j++)
{
if (nums[j] + nums[i] == target)
{
result.push_back(i);
result.push_back(j);
}
else
;
}
}
return result;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  leetcode