javascript webpack配置
- 题目1:数组查找指定和的下标 ``` 输入:nums = [2,7,11,15], target = 9 输出:[0,1] 解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。
*** 尝试双层遍历 ***
return{
isAdgust: true,
arr: [],
target: 0,
newArr: [],
} }, methods: {
checkIndex: function (arr, target) {
this.arr = arr;
this.target = target;
this.newArr = [];
for(let i = 0; i < arr.length; i++){
for(let j = 1;j<=arr.length;j++){
if(arr[i]+arr[j]===target){
this.newArr.push([i,j]);
}
}
}
this.isAdgust = false;
console.warn(this.newArr);
}, }, ```