Best Solution with proper explanation. Beats 100% and 0ms. Trust:)
Intuition\n Describe your first thoughts on how to solve this problem. \nFirst map a map, then sort the nums array acoording to the values in the map\n# Approac
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst map a map, then sort the nums array acoording to the values in the map\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- make a map, iterate through the nums array and store the frequencies in the map\n- sort the nums array according to the lambda function where\n- - if the frequencing are same, return if the first value is bigger than the secon\n- - else return true if the frequency of first element is greater than the frequency of second.\n- return the newly sorted array \n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$- making the map\n$$O(nlogn)$$- for sorting \n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$- due to the space the map takes\n# Code\n```\nfunc frequencySort(nums []int) []int {\n    mapp:= make(map[int]int)\n    n:= len(nums)\n    if n==1{\n        return nums\n    }\n    for i:=0;i<n;i++{\n        mapp[nums[i]]++\n    }\n    sort.Slice(nums, func(i, j int)bool{\n        if mapp[nums[i]]==mapp[nums[j]]{\n            return nums[i]>nums[j]\n        }\n        return mapp[nums[i]]<mapp[nums[j]]\n    })\n    return nums\n}\n```\n\nIf you found this helpful, kindly upvote, the button is on the bottom left corner.
['Array', 'Hash Table', 'Sorting', 'C++', 'Go']