Closed yuyuyu-alan closed 2 years ago
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]], []) }
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]], []) }