package leetcode;

/**
 * https://leetcode.com/problems/second-largest-digit-in-a-string/
 */
public class Problem1796 {
    public int secondHighest(String s) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1796 prob = new Problem1796();
        System.out.println(prob.secondHighest("dfa12321afd")); // 2
        System.out.println(prob.secondHighest("abc1111")); // -1
    }
}

@@ -167,264 +167,621 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1796 prob = new Problem1796();%0A        System.out.println(prob.secondHighest(%22dfa12321afd%22)); // 2%0A        System.out.println(prob.secondHighest(%22abc1111%22)); // -1
+int max = -1;%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            char c = s.charAt(i);%0A            if (c %3C '0' %7C%7C c %3E '9') %7B%0A                continue;%0A            %7D%0A            int num = c - '0';%0A            max = Math.max(max, num);%0A        %7D%0A        int answer = -1;%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            char c = s.charAt(i);%0A            if (c %3C '0' %7C%7C c %3E '9') %7B%0A                continue;%0A            %7D%0A            int num = c - '0';%0A            if (max == num) %7B%0A                continue;%0A            %7D%0A            answer = Math.max(answer, num);%0A        %7D%0A        return answer;
 %0A   

Solve problem 1796