Title: #1636 - Sort Array by Increasing Frequency - LeetCode JavaScript Solutions
Open Graph Title: #1636 - Sort Array by Increasing Frequency - LeetCode JavaScript Solutions
X Title: #1636 - Sort Array by Increasing Frequency - LeetCode JavaScript Solutions
Description: Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same f...
Open Graph Description: Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same f...
X Description: Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same f...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/sort-array-by-increasing-frequency
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/sort-array-by-increasing-frequency","name":"#1636 - Sort Array by Increasing Frequency - LeetCode JavaScript Solutions","description":"Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same f...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[]} nums\n * @return {number[]}\n */\nvar frequencySort = function(nums) {\n const map = new Map();\n nums.forEach(num => map.set(num, (map.get(num) || 0) + 1));\n\n return nums.sort((a, b) => {\n const freqA = map.get(a);\n const freqB = map.get(b);\n return freqA === freqB ? b - a : freqA - freqB;\n });\n};","keywords":"LeetCode 1636, #1636 - Sort Array by Increasing Frequency, Easy, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/sort-array-by-increasing-frequency |
| twitter:image | https://leetcodejavascript.com/og-image.jpg |
| twitter:creator | @joshcrozier |
| theme-color | #1f2937 |
Links:
| LeetCodeJavascript.com | https://leetcodejavascript.com/ |
| Star on GitHub | https://github.com/JoshCrozier/leetcode-javascript |
| Back to all solutions | https://leetcodejavascript.com |
| View on LeetCode | https://leetcode.com/problems/sort-array-by-increasing-frequency/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/1636-sort-array-by-increasing-frequency.js |
| Array | https://leetcodejavascript.com/tags/array |
| Hash Table | https://leetcodejavascript.com/tags/hash-table |
| Sorting | https://leetcodejavascript.com/tags/sorting |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow