Given integer array nums, return the third maximum number in this array. If the third maximum does not exist, return the maximum number.
This problem seems easy but lots of hazards. We need three maximum numbers to record first, second, and third. And we update them in turn. But without the third maximum number, we shall return maximum number. So the question is when we do not have the third maximum number, when the third maximum number do not update. So we need to record the third value changes or not. If we use a bool in the update of the third maximum number, it's wrong. Because, the first number update, may affect the third or not, it's decided by the second maximum number has a value or not. Thus, a simpler idea is to check the third maximum number changes or not. But the third maximum number can be any number of int. Thus, we initialize the third maximum number with the long min. Problem solve.
Also, the same number shall be consider once. The condition will be >= or > second and < first. > second = first shall not be considered.
AC!