Skip to content

Commit f6cb812

Browse files
edit 414
1 parent d76d1e6 commit f6cb812

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Your ideas/fixes/algorithms are more than welcome!
177177
|417|[Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow/)|[Solution](../master/src/main/java/com/fishercoder/solutions/PacificAtlanticWaterFlow.java) | O(m*n*Max(m,n)) |O(m*n) | Medium| DFS
178178
|416|[Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_416.java)| O(m*n)|O(m*n) | Medium | DP
179179
|415|[Add Strings](https://leetcode.com/problems/add-strings/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_415.java)| O(n)|O(1) | Easy|
180-
|414|[Third Maximum Number](https://leetcode.com/problems/third-maximum-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/ThirdMaximumNumber.java)| O(n)|O(1) | Easy|
180+
|414|[Third Maximum Number](https://leetcode.com/problems/third-maximum-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_414.java)| O(n)|O(1) | Easy|
181181
|413|[Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_413.java) | O(n) |O(1) | Medium| DP
182182
|412|[Fizz Buzz](https://leetcode.com/problems/fizz-buzz/)|[Solution](../master/src/main/java/com/fishercoder/solutions/FizzBuzz.java)| O(n)|O(1) | Easy|
183183
|411|[Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_411.java)| O(?)|O(?) | Hard| NP-Hard, Backtracking, Trie, Recursion

src/main/java/com/fishercoder/solutions/ThirdMaximumNumber.java renamed to src/main/java/com/fishercoder/solutions/_414.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.fishercoder.solutions;
22

3-
/**Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).
3+
/**
4+
* 414. Third Maximum Number
5+
*
6+
* Given a non-empty array of integers, return the third maximum number in this array.
7+
* If it does not exist, return the maximum number. The time complexity must be in O(n).
48
59
Example 1:
610
Input: [3, 2, 1]
@@ -22,9 +26,9 @@
2226
Explanation: Note that the third maximum here means the third maximum distinct number.
2327
Both numbers with value 2 are both considered as second maximum.
2428
*/
25-
public class ThirdMaximumNumber {
29+
public class _414 {
2630

27-
public static int thirdMax_20161115(int[] nums) {
31+
public static int thirdMax(int[] nums) {
2832

2933
if (nums == null || nums.length == 0) return 0;
3034
if (nums.length < 3) {
@@ -73,7 +77,7 @@ public static void main(String...strings){
7377
int[] nums = new int[]{1,2,-2147483648};//should be -2147483648
7478
// int[] nums = new int[]{3,2,1};
7579
// System.out.println(thirdMax(nums));
76-
System.out.println(thirdMax_20161115(nums));
80+
System.out.println(thirdMax(nums));
7781
}
7882

7983
}

0 commit comments

Comments
 (0)