We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
'abcaakjbb' => {'a':2,'b':2} 'abbkejsbcccwqaa' => {'c':3}
The text was updated successfully, but these errors were encountered:
const arr = str.match(/(\w)\1*/g); const maxLen = Math.max(...arr.map(s => s.length)); const result = arr.reduce((pre, curr) => { if (curr.length === maxLen) { pre[curr[0]] = curr.length; } return pre; }, {}); console.log(result);
Sorry, something went wrong.
不考虑空间和时间复杂度,- .. -
function findMost(str) { const m = new Map(); for (let s of str) { if (m.has(s)) { m.set(s, m.get(s) + 1); } else { m.set(s, 1); } } const maxValue = Math.max.apply(null, [...m.values()]); let res = {}; for (let [k, v] of m.entries()) { if (maxValue === v) { res[k] = v; } } return res; }
No branches or pull requests
The text was updated successfully, but these errors were encountered: