兩數之和解題思路

Java(題目來源:LeetCode)Here (1)建立哈希表Map<Integer, Integer> map = new HashMap<>(); 其中map的key是nums[i],value是i(nums數組中的值以及它對應的數組下標) (2)遍歷nums數組並做判斷 temp = target - i; if( map.containsKey(temp)) 如果存在,直接返回 retu
相關文章
相關標籤/搜索