why am I wrong


  • -1
    J

    public:
    vector<int> twoSum(vector<int>& nums, int target) {
    int l=nums.size();
    vector<int> result;
    for(int i=0;i++;i<l-1)
    for(int j=i+1;j++;j<l)
    {if (nums[i]+nums[j]==target)
    { result.push_back(i+1);
    result.push_back(j+1);
    return result;
    }
    }
    return result;
    }
    0_1507643359458_f5be5cf9-e1a5-48c1-bd54-cae5b393bbf1-image.png
    class Solution {
    public:
    vector<int> twoSum(vector<int>& nums, int target) {
    vector<int> result;
    int l=nums.size();
    for(int i=0;i<l-1;i++)
    for(int j=i+1;j<l;j++)
    {if (nums[i]+nums[j]==target)
    { result.push_back(i);
    result.push_back(j);
    return result;
    }
    }
    return result;
    }
    };
    0_1507644213181_39fcb89d-038a-4566-a94a-51774d4c798e-image.png


Log in to reply
 

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