Last active
September 2, 2018 02:27
-
-
Save zhangxiaomu01/d34f9703d461584eeada11ab5eea428c to your computer and use it in GitHub Desktop.
CPP Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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