Skip to content

[js] 第1天 用递归算法实现,数组长度为5且元素的随机数在2-32间不重复的值 #3

Open
@haizhilin2013

Description

@haizhilin2013

这一题是起源题

描述:

  1. 这是一道大题目,把考点拆成了4个小项;需要侯选人用递归算法实现(限制15行代码以内实现;限制时间10分钟内完成):
    a) 生成一个长度为5的空数组arr。
    b) 生成一个(2-32)之间的随机整数rand。
    c) 把随机数rand插入到数组arr内,如果数组arr内已存在与rand相同的数字,则重新生成随机数rand并插入到arr内[需要使用递归实现,不能使用for/while等循环]
    d) 最终输出一个长度为5,且内容不重复的数组arr。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    jsJavaScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions