题解 | #高频数据类型#

高频数据类型

https://www.nowcoder.com/practice/687425f78096428baa58fbdcf024244a

            const _findMostType = array => {
                // 补全代码
                let tem = {}
                let arr = []
                let num = 0
                for(let key of array) {
                    const type = typeof key
                    tem[type] = (tem[type] || 0) + 1
                    num = Math.max(num, tem[type])
                }
                for (let key in tem) {
                    if(tem[key] === num) {
                        arr.push(key)
                    }
                }
                return [...arr, num]
            }

全部评论

相关推荐

09-14 17:23
门头沟学院
故事和酒66:所以说副业很重要,程序员干到40岁,再怎么也赚300万了,吃吃利息也够活下去
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务