问题描述
解题思路
遍历就好了
代码
class Solution {
public:
int secondHighest(string s) {
int first = -1;
int second = -1;
for (int i = 0; i < s.size(); i++) {
if (s[i] <= '9') {
if (s[i] - '0' > first) {
second = first;
first = s[i] - '0';
} else if (s[i] - '0' < first && s[i] - '0' > second)
second = s[i] - '0';
}
}
return second;
}
};
标签:digit,string,int,1796,second,字符串,first
From: https://www.cnblogs.com/zwyyy456/p/16960338.html