TwoSum C++ using Vector not working!


  • 0
    B

    This is what it shows when I run the code:

    "Line 24: too few arguments to function 'std::__debug::vector<int> Solution(std::__debug::vector<int>&, int)"
    
    vector<int> Solution(vector<int> &nums,int target)
    {
        vector<int> result;
        int i,j;
        for(i=0;i<nums.size();i++)
        {
            for(j=0;j<nums.size();j++)
            {
                if((nums[i]+nums[j])==target)
                {
                     result.push_back(i+1);
                     result.push_back(j+1);
                     //return result;
                }
            }
        }
        return result;
    }
    

  • 0
    S

    the function name is 'twoSum'. and 'Solution' is the class name.


Log in to reply
 

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