腾讯0906前端笔试代码

  1. 将两个有序数组合并成一个有序数组(注意读取数组的时候进行格式转化)
  2. JSON对象扁平化:类似一个计数器,每个1s会输出一个数字,如果没有输出就是0,给出的范例如下:
    // 输入:{"1":256,"2":290,"8":"332"}(JSON)
    // 要求输出:[256,290,0,0,0,0,0,332](JSON) 

  3. 找中位数
    // 输入:
// 第一行数字个数:n(输入的数字个数,如6)
// 第二行数字: 1,2,3,4,5,6


// 输出:删除ai(i<n)之后剩余数字的中位数
// 3  
// 3
// 3
// 4
// 4
// 4
  1. 实例化一个Canlender组件
function Calendar(container, year, month) {
    this.year = year;
    this.month = month;
    this.html = html;
    this.el = null; //TODO: 创建分页组件根节点
    if (!el) return;
    this.el.className = 'calendar';
    this.el.innerHTML = this.html();
    container.appendChild(this.el);

    this.el.addEventListener('click', event => {
        var el = event.target;
        var isPre = el.classList.contains('pre');
        var isNext = el.classList.contains('next');
        if (!isPre && !isNext) return;
        if (isPre) {
           el.className = "current";   
                 
            //TODO: 更新this.month和this.year
        } else {
            //TODO: 更新this.month和this.year
           
        }
        this.el.innerHTML = this.html();
    });

    function html() {
        var date = new Date();
        var year = +this.year || 0;
        var month = (+this.month || 0) - 1;
        var day = date.getDate();
        //TODO: 生成组件的内部html字符串
        return '';
    }
}
  1. 数字消消乐
    // 输入第一行:n(字符串的行数)
    // 之后n行字符串
    
    // 输出:每行数字串可被消除的次数(前后相等的两个数字可被消除)
    
    
    
    
    // 例子:
    // 输入:
    // 2
    // 43211234
    // 101
    
    // 输出:
    // 4  43211234->432234->4334->44->
    // 0  101
    
    
    
    
#笔经##腾讯#
全部评论
找中位数这个怎么A不过去呢?
点赞
送花
回复 分享
发布于 2020-09-06 23:25
有答案吗  想看看
点赞
送花
回复 分享
发布于 2020-09-07 11:11
秋招专场
校招火热招聘中
官网直投

相关推荐

点赞 评论 收藏
分享
点赞 9 评论
分享
牛客网
牛客企业服务