File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
algorithms/Third Maximum Number Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -611,7 +611,7 @@ LeetCode solutions with JavaScript
611
611
| 417 | [ Pacific Atlantic Water Flow] ( https://leetcode.com/problems/pacific-atlantic-water-flow/ ) | | | Medium |
612
612
| 416 | [ Partition Equal Subset Sum] ( https://leetcode.com/problems/partition-equal-subset-sum/ ) | | | Medium |
613
613
| 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 |
615
615
| 413 | [ Arithmetic Slices] ( https://leetcode.com/problems/arithmetic-slices/ ) | | | Medium |
616
616
| 412 | [ Fizz Buzz] ( https://leetcode.com/problems/fizz-buzz/ ) | | | Easy |
617
617
| 411 | [ Minimum Unique Word Abbreviation] ( https://leetcode.com/problems/minimum-unique-word-abbreviation/ ) | | | Hard |
Original file line number Diff line number Diff line change
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
+ } ;
You can’t perform that action at this time.
0 commit comments