same thought. Mine is a little complicated.

public int thirdMax(int[] nums) { int len = nums.length; if(len == 1){ return nums[0]; } if(len == 2){ return Math.max(nums[0],nums[1]); } long first = -2147483649L; long second = -2147483649L; long third = -2147483649L; for(int i = 0;i<len;i++){ if(nums[i]>first){ third = second; second = first; first = nums[i]; }else if(nums[i]!=first && nums[i]>second){ third = second; second = nums[i]; }else if(nums[i]!=first && nums[i]!=second && nums[i]>third){ third = nums[i]; }else{ continue; } } return third == -2147483649L?(int)first:(int)third; }Third Maximum Number