题解 | #无重复数组#

无重复数组

https://www.nowcoder.com/practice/d2fa3632268b41df9bc417b74802ad8c

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
    </head>
    <body>

        <script>
            const _getUniqueNums = (start,end,n) => {
                // 补全代码
             let arr = [];
              while(arr.length<n){
                  let v =Math.floor(Math.random()*(end-1)+start)
                  if(arr.indexOf(v)===-1){
                      arr.push(v)
                  }
              }
                return arr
            }
        </script>
    </body>
</html>
全部评论

相关推荐

头发暂时没有的KFC总裁:找廉价劳动力罢了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务