题解 | #无重复数组#
无重复数组
http://www.nowcoder.com/practice/d2fa3632268b41df9bc417b74802ad8c
const _getUniqueNums = (start, end, n) => {
// 补全代码
let flag = true
let res = []
while (flag) {
let temp = Math.floor(Math.random() * (end + 1 - start)) + start
if (res.indexOf(temp) === -1) {
res.push(temp)
flag = res.length === n ? false : true
}
}
return res
}