Skip to content

Commit

Permalink
feat: add solution of 414th problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Chersquwn committed May 31, 2019
1 parent f5ae7d9 commit 1c4de25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ LeetCode solutions with JavaScript
| 417 | [Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow/) | | | Medium |
| 416 | [Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum/) | | | Medium |
| 415 | [Add Strings](https://leetcode.com/problems/add-strings/) | | | Easy |
| 414 | [Third Maximum Number](https://leetcode.com/problems/third-maximum-number/) | | | Easy |
| 414 | [Third Maximum Number](https://leetcode.com/problems/third-maximum-number/) | | [JavaScript](./algorithms/Third%20Maximum%20Number/index.js) | Easy |
| 413 | [Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices/) | | | Medium |
| 412 | [Fizz Buzz](https://leetcode.com/problems/fizz-buzz/) | | | Easy |
| 411 | [Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation/) | | | Hard |
Expand Down
10 changes: 10 additions & 0 deletions algorithms/Third Maximum Number/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// problem https://leetcode.com/problems/third-maximum-number/

/**
* @param {number[]} nums
* @return {number}
*/
const thirdMax = function (nums) {
const sorted = [...new Set(nums)].sort((a, b) => b - a)
return sorted[2] !== undefined ? sorted[2] : sorted[0]
};

0 comments on commit 1c4de25

Please sign in to comment.