Today is the first day of Leetcode, but not very well. Do this, I can't believe
Original topic:
I give the answer:
1 classSolution {2 Public:3vector<int> Twosum (vector<int>& Nums,inttarget) {4vector<int>result;5 for(inti =0; I <nums.size (); i + +){6 for(intj = i+1; J <nums.size (); J + +){7 if(Nums[i] + nums[j] = =target) {8 Result.push_back (i); The first thing to do is to pass the subscript of the computed array to a vector, failing9 Result.push_back (j);Ten returnresult; One } A - } - } the returnresult; - } -};
The first thing to do is to pass the subscript of the computed array to a vector, failing
Secondly, the computational complexity of this is particularly large and clearly does not conform to the standards required by the company.
Leetcode_ input an array, target tree, check the target is the array subscript of which two of the sum, no repetition