int thirdMax(int* nums, int numsSize){ long long first = -2147483649; long long second = -2147483649; long long third = -2147483649; for (int i=0; i<numsSize; i++) { if (nums[i] > first) { long long temp = second; second = first; first = nums[i]; third = temp; } else if (nums[i] > second && nums[i] < first) { third = second; second = nums[i]; } else if (nums[i] > third && nums[i] < second) third = nums[i]; } if (third == -2147483649) return first; return third; }