---
# System prepended metadata

title: Leetcode 414. Third Maximum Number
tags: [skip, Array]

---

# Leetcode 414. Third Maximum Number
# Long.MIN_VALUE
可跳過這題(太簡單)

Runtime: 0 ms
faster than 100.00% 
``` java=
class Solution {
    public int thirdMax(int[] nums) {
        long firstMaximum=Long.MIN_VALUE,
            secondMaximum=Long.MIN_VALUE,
            thirdMaximum=Long.MIN_VALUE;
        
        for(long temp : nums){
            if(temp>firstMaximum){
                thirdMaximum=secondMaximum;
                secondMaximum=firstMaximum;
                firstMaximum=temp;
                continue;
            }
            else if(temp>secondMaximum && temp!=firstMaximum){
                thirdMaximum=secondMaximum;
                secondMaximum=temp;
                continue;
            }
            else if(temp>thirdMaximum && temp!=secondMaximum && temp!=firstMaximum){
                thirdMaximum=temp;
                continue;
            }
        }
        
        return thirdMaximum==Long.MIN_VALUE?(int)firstMaximum:(int)thirdMaximum;
    }
}
```


---

###### tags: `Array` `skip`