shfshanyue / Daily-Question

互联网大厂内推及大厂面经整理,并且每天一道面试题推送。每天五分钟,半年大厂中

Home Page:https://q.shanyue.tech

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

代码

yuyuyu-alan opened this issue · comments

commented

const getFrequentChar = (str) => { let maps = new Map(); for(let i of str) { maps.set(i, maps.has(i) ? maps.get(i) + 1 : 0) } return [...maps].reduce((a, b) => a[1] > b[1] ? [a[0], a[1]] : [b[0], b[1]], []) }