Title: #414 - Third Maximum Number - LeetCode JavaScript Solutions
Open Graph Title: #414 - Third Maximum Number - LeetCode JavaScript Solutions
X Title: #414 - Third Maximum Number - LeetCode JavaScript Solutions
Description: Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum...
Open Graph Description: Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum...
X Description: Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/third-maximum-number
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/third-maximum-number","name":"#414 - Third Maximum Number - LeetCode JavaScript Solutions","description":"Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[]} nums\n * @return {number}\n */\nvar thirdMax = function(nums) {\n const sortedSet = [...new Set(nums)].sort((a, b) => a - b);\n const thirdMax = sortedSet[sortedSet.length - 3];\n\n return thirdMax !== undefined\n ? thirdMax\n : sortedSet[sortedSet.length - 1];\n};","keywords":"LeetCode 414, #414 - Third Maximum Number, 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/third-maximum-number |
| 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/third-maximum-number/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0414-third-maximum-number.js |
| Array | https://leetcodejavascript.com/tags/array |
| Sorting | https://leetcodejavascript.com/tags/sorting |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow