算法题leetCode
1.两数之和
简单题
var twoSum = function (nums, target) {
const length = nums.length
const m = new Map()
const res = []
for (let i = 0; i < length; i++) {
let a = target - nums[i]
if (m.has(a)) {
res.push(m.get(a), i)
}
m.set(nums[i], i)
}
retu
原创
2021-07-31 17:15:50 ·
110 阅读 ·
0 评论