题目描述
进阶考虑:
方法一:
双循环
class Solution {
public int[] twoSum(int[] nums, int target) {
for(int i = 0;i
运行截图
总结:
使用for循环虽然简单粗暴,且容易理解,但是费时费内存
方法二(考虑进阶):
使用Java提供的Map集合存储数组值和数组值对应的下标
class Solution {
public int[] twoSum(int[] nums, int target) {
Map map = new HashMap<>();
for(int i = 0;i
运行截图



