leet code 1. 两数之和
作者:互联网
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> solution;
for(int i = 0; i < nums.size(); i++)
{
for(int j = 0; j < nums.size(); j++)
{
if(i != j)
{
if(nums[i] + nums[j] == target)
{
solution.push_back(i);
solution.push_back(j);
break;
}
}
}
if (!solution.empty())
{
break;
}
}
return solution;
}
};
标签:leet,code,target,nums,int,solution,back,vector,两数 来源: https://blog.csdn.net/qq_28371533/article/details/95091586