class Solution {
public int secondHighest(String s) {
int max1 = -1;
int max2 = -1;
char[] ch = s.toCharArray();
int n = ch.length;
for (int i = 0; i < n; i++) {
if (ch[i] >= '0' && ch[i] <= '9') {
int num = ch[i] - '0';
max1 = Math.max(max1, num);
}
}
for (int i = 0; i < n; i++) {
if (ch[i] >= '0' && ch[i] <= '9') {
int num = ch[i] - '0';
if (num < max1) {
max2 = Math.max(max2, num);
}
}
}
return max2;
}
}
标签:ch,数字,int,1796,&&,字符串
From: https://www.cnblogs.com/eiffelzero/p/16946289.html