package leetcode;

/**
 * https://leetcode.com/problems/third-maximum-number/
 */
public class Problem414 {
    public int thirdMax(int[] nums) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem414 prob = new Problem414();
        System.out.println(prob.thirdMax(new int[]{3, 2, 1})); // 1
        System.out.println(prob.thirdMax(new int[]{1, 2})); // 2
        System.out.println(prob.thirdMax(new int[]{2, 2, 3, 1})); // 1
    }
}

@@ -151,333 +151,1105 @@
     
-// TODO%0A        return 0
+Integer max1 = null;%0A        Integer max2 = null
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem414 prob = new Problem414();%0A        System.out.println(prob.thirdMax(new int%5B%5D%7B3, 2, 1%7D)); // 1%0A        System.out.println(prob.thirdMax(new int%5B%5D%7B1, 2%7D)); // 2%0A        System.out.println(prob.thirdMax(new int%5B%5D%7B2, 2, 3, 1%7D)); // 1
+Integer max3 = null;%0A        for (int i = 0; i %3C nums.length; i++) %7B%0A            if (max1 == null) %7B%0A                max1 = nums%5Bi%5D;%0A                continue;%0A            %7D%0A            if (max1 == nums%5Bi%5D) %7B%0A                continue;%0A            %7D%0A            if (max1 %3C nums%5Bi%5D) %7B%0A                max3 = max2;%0A                max2 = max1;%0A                max1 = nums%5Bi%5D;%0A                continue;%0A            %7D%0A            if (max2 == null) %7B%0A                max2 = nums%5Bi%5D;%0A                continue;%0A            %7D%0A            if (max2 == nums%5Bi%5D) %7B%0A                continue;%0A            %7D%0A            if (max2 %3C nums%5Bi%5D) %7B%0A                max3 = max2;%0A                max2 = nums%5Bi%5D;%0A                continue;%0A            %7D%0A            if (max3 == null) %7B%0A                max3 = nums%5Bi%5D;%0A            %7D%0A            if (max3 == nums%5Bi%5D) %7B%0A                continue;%0A            %7D%0A            if (max3 %3C nums%5Bi%5D) %7B%0A                max3 = nums%5Bi%5D;%0A                continue;%0A            %7D%0A        %7D%0A        return (max3 == null) ? max1 : max3;
 %0A   

Solve problem 414