Advertisement
momo2345

two sum

Jul 12th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     vector<int> twoSum(vector<int>& nums, int target) {
  4.         vector<int>m;
  5.        
  6.         for(int i=0;i<nums.size();i++){
  7.            
  8.             for(int j=i+1;j<nums.size();j++){
  9.                 if(nums[i]+nums[j]==target){
  10.                     m.push_back(i);
  11.                     m.push_back(j);
  12.                 }
  13.             }
  14.         }
  15.         return m;
  16.        
  17.     }
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement