给定一个整数数列,找出其中和为特定值的那两个数。
直接两次遍历比较;时间复杂度是o(n2)
如果用一个map来存储target-a,来寻找另一数字,随着每次的查找,map中对于每个元素的补数渐渐完整,而在map中查找的不算时间,所以时间复杂度会为o(n);
当然要注意要排除本身;
int []a=new int[2];
Map<Integer,Integer> map=new HashMap<Integer,Integer>();
for(int i=0;i<nums.length;i++)
{
int b=target-nums[i];
if(map.containsKey)
}