求教,不小心在lawn上撒上除草剂了。该怎么弄# gardening - 拈花惹草
c*z
1 楼
source code is as below,
vector twoSum(vector &numbers, int target) {
unordered_map m;
unordered_map::iterator it;
vector output;
int count = 1;
for ( int i = 0; i < numbers.size(); i++ )
{
if ( m.find( target - numbers[i] ) == m.end() )
m[numbers[i]];
else
{
for ( it = m.begin(); it != m.end(); it++ )
{
if ( it == m.find( target - numbers[i] ) )
{
output.push_back(count);
output.push_back(i+1);
break;
}
count++;
}
}
}
return output;
}
vector
unordered_map
unordered_map
vector
int count = 1;
for ( int i = 0; i < numbers.size(); i++ )
{
if ( m.find( target - numbers[i] ) == m.end() )
m[numbers[i]];
else
{
for ( it = m.begin(); it != m.end(); it++ )
{
if ( it == m.find( target - numbers[i] ) )
{
output.push_back(count);
output.push_back(i+1);
break;
}
count++;
}
}
}
return output;
}