Skip to content

Instantly share code, notes, and snippets.

@zhangxiaomu01
Last active September 2, 2018 02:27
Show Gist options
  • Save zhangxiaomu01/d34f9703d461584eeada11ab5eea428c to your computer and use it in GitHub Desktop.
Save zhangxiaomu01/d34f9703d461584eeada11ab5eea428c to your computer and use it in GitHub Desktop.
CPP Test
//Brute Force for two sum problems
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> Result;
int len = nums.size();
for(int i = 0; i< len; i++)
{
for(int j = i+1; j< len; j++)
{
if(nums[i]+nums[j] == target)
{
Result.push_back(i);
Result.push_back(j);
return Result;
}
}
}
return Result;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment