```
class Solution {
public:
int thirdMax(vector<int>& nums) {
int max,mid,min;
int count = 0;
int bottom = 0;
max=mid=min=0x80000000;
for(int i = 0; i< nums.size();i++){
if(nums[i] == 0x80000000) bottom = 1;
if(nums[i] == max || nums[i] == mid || nums[i] == min) continue;
if(nums[i] > max){
min = mid;
mid = max;
max = nums[i];
count ++;
}else if(nums[i] > mid) {
min = mid;
mid = nums[i];
count ++;
}else if(nums[i] > min){
min = nums[i];
count++;
}
}
if(count + bottom >=3) return min;
else return max;
}
};
```