/*
* @lc app=leetcode.cn id=1 lang=javascript
*
* [1] 两数之和
*/
// @lc code=start
/**
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
//1.两数之和
var twoSum = function(nums, target) {
let arr = nums;
let arrs = new Array()
for (let i = 0; i < nums.length; i++) {
for (let j = i + 1; j < nums.length; j++) {
if (nums[i] + nums[j] === target) {
return [i, j]
}
}
}
}
//
console.log(twoSum([2, 7, 11, 15],9))
LeetCode :1. 两数之和(JavaScript)
最新推荐文章于 2022-03-22 18:19:33 发布