LeetCode 1. 两数之和
1 class Solution { 2 public: 3 vector<int> twoSum(vector<int>& nums, int target) { 4 vector<int> v; 5 for(int i = 0; i < nums.size(); ++i) 6 for(int j = 0; j < nums.size(); ++j) 7 if(nums[i] + nums[j] == target && i != j) 8 { 9 v.push_back(i); 10 v.push_back(j); 11 return v; 12 } 13 } 14 };