Skip to content

Commit 1c4de25

Browse files
committed
feat: add solution of 414th problem
1 parent f5ae7d9 commit 1c4de25

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ LeetCode solutions with JavaScript
611611
| 417 | [Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow/) | | | Medium |
612612
| 416 | [Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum/) | | | Medium |
613613
| 415 | [Add Strings](https://leetcode.com/problems/add-strings/) | | | Easy |
614-
| 414 | [Third Maximum Number](https://leetcode.com/problems/third-maximum-number/) | | | Easy |
614+
| 414 | [Third Maximum Number](https://leetcode.com/problems/third-maximum-number/) | | [JavaScript](./algorithms/Third%20Maximum%20Number/index.js) | Easy |
615615
| 413 | [Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices/) | | | Medium |
616616
| 412 | [Fizz Buzz](https://leetcode.com/problems/fizz-buzz/) | | | Easy |
617617
| 411 | [Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation/) | | | Hard |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// problem https://leetcode.com/problems/third-maximum-number/
2+
3+
/**
4+
* @param {number[]} nums
5+
* @return {number}
6+
*/
7+
const thirdMax = function (nums) {
8+
const sorted = [...new Set(nums)].sort((a, b) => b - a)
9+
return sorted[2] !== undefined ? sorted[2] : sorted[0]
10+
};

0 commit comments

Comments
 (0)