most frequently occurring character
2022年5月1日小于 1 分钟
most frequently occurring character
Question
Given a non-empty string, return the most frequently ocurring character.
If there are multiple characters with same occurrance, return an array of them.
count('abbccc')
// 'c'
count('abbcccddd')
// ['c', 'd']
Follow-up: What is the time & space complexity of your approach?
Code
/**
* @param {string} str
* @returns {string | string[]}
* /
function count(str) {
// your code here
}