DEV Community

Nitin Ahirwal
Nitin Ahirwal

Posted on

πŸš€ Day 7 of My LeetCode Challenge β€” 3005. Count Elements With Maximum Frequency

Today’s problem: LeetCode 3005 β€” Count Elements With Maximum Frequency πŸ”’

Task: Find the max frequency in an array and count how many elements belong to it.

Approach:

Use a Map to count frequencies

Find the maximum frequency

Sum all counts equal to that maximum

⚑ Time Complexity: O(n)
πŸ’Ύ Space Complexity: O(k)

πŸ‘‰ Full write-up with code + video walkthrough:
[https://nitinahirwal.in/posts/3005-CountElementsWithMaximumFrequency]

πŸŽ₯ Walkthrough video: [https://youtu.be/qyptT7sp_gg]

LeetCode #JavaScript #100DaysOfCode #HashMap

Top comments (0)