算法总结-每日一题-(10月22日停更,搞别的专题去了)
1.两数之和
思路:
1.考虑hash表,key为数组元素对应的值,value为下标,
2.考虑只循环一次,将target减去某一个值。再看原来数组里是否包含剩下的
public static int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++
原创
2021-09-17 19:25:55 ·
345 阅读 ·
0 评论