Why I can go through the vs2015,, but can not pass on the internet,,{ -3,4,3,90 } 0 ?


  • 0
    class Solution {
    public:
    	vector<int> twoSum(vector<int>& nums, int target) {
    		map<int, int> m;
    		for (size_t  i = 0; i < nums.size(); i++)
    		{
    			m[nums[i]] = i;
    		}
    		for (size_t i = 0; i < nums.size(); i++)
    		{
    			
    			if (nums[i] != target - nums[i] && m.find(target - nums[i])!=m.end())
    			{
    				vector<int> v;
    				v.push_back(m[nums[i]]);
    				v.push_back(m[target - nums[i]]);
    				return v;
    			}
    		}
    		
    	}
    };

  • 0
    L

    There is not always a return value in your function, which may cause a compile error


  • 0

    OK, let me think a while


  • 0
    N
    This post is deleted!

Log in to reply
 

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