Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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