TGViewer
Data Science Data Science @datascienceofficial · 359 subscribers
Post #391 16
1st Code

var majorityFrequencyGroup = function(s) {
const freqMap = new Map();
for (const char of s) {
freqMap.set(char, (freqMap.get(char) || 0) + 1);
}

const groups = new Map();
for (const [char, freq] of freqMap.entries()) {
if (!groups.has(freq)) groups.set(freq, []);
groups.get(freq).push(char);
}

let bestSize = -1, bestFreq = -1;
let bestGroup = [];
for (const [freq, chars] of groups.entries()) {
const groupSize = chars.length;
if (groupSize > bestSize || (groupSize === bestSize && freq > bestFreq)) {
bestSize = groupSize;
bestFreq = freq;
bestGroup = chars;
}
}

return bestGroup.join('');
};

Join👇

    @leetcode_cp
      @leetcode_cp
More from @datascienceofficial
  1. Oct 11, 2026🧠 Data Science Skill: Turn Messy Business Data Into Decisions Real data science is not on…
  2. Oct 10, 2026You can connect or follow me on Linked[in] https://www.linkedin.com/in/subarno-roy-3b22513…
  3. Oct 10, 2026Daily High-Accuracy Quotex Signals ✅ ​ ​Our signals focus on key price action levels, tren…
  4. Oct 9, 2026🚨 Earn Passive Money Easily 🚨 Since your device is already connected to the internet, yo…
  5. Oct 8, 2026INDIA'S BIGGEST SHOPPING SALE IS LIVE TOMORROW IS IT REALLY A DEAL🤡? THIS APP BUYHATKE TE…
  6. Oct 3, 2026𝗧𝗵𝗼𝘀𝗲 𝘄𝗵𝗼 𝘄𝗮𝗻𝘁 𝗿𝗲𝗳𝗲𝗿𝗿𝗮𝗹𝘀 𝗮𝗻𝗱 𝗝𝗼𝗯𝘀 𝗮𝗻𝗱 𝗜𝗻𝘁𝗲𝗿𝗻𝘀𝗵𝗶𝗽�…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →