c++ easy solution


  • 0
    M

    class Solution {
    public:
    vector<int> twoSum(vector<int>& nums, int target) {
    vector<int> conums=nums;
    vector<int> ans;
    int number=conums.size();
    for(int i=0;i<number-1;i++)
    for(int j=i+1;j<number;j++)
    {
    if(conums[i]+conums[j]==target)
    {
    ans.push_back(i);
    ans.push_back(j);
    return ans;
    }
    }
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.