Array - 32: Sort array based on frequency of value (If frequency is same then sort based on value)

Опубликовано: 01 Октябрь 2024
на канале: Coding Simplified
38,704
424

Source Code:https://thecodingsimplified.com/sort-...
Solution:
- Iterate all element of array & put in map (key as number & value as frequency)
- Now map has all value with their frequency
- Now use comparator & compare based on their map value
- If frequency is same then compare using value of array element

Time complexity: O(nlogn)
Space Complexity: O(n)

Do Watch video for more info

CHECK OUT CODING SIMPLIFIED
   / codingsimplified  

★☆★ VIEW THE BLOG POST: ★☆★
http://thecodingsimplified.com

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
https://www.youtube.com/codingsimplif...

★☆★ Send us mail at: ★☆★
Email: [email protected]