1class Solution {2public:3int secondHighest(string s) {4// support variables5int res[2] = {-1, -1};6// parsing s7for (char c : s) {8// considering only numerical characters9if (c >= '0' && c <= '9') {10// normalising c11c -= '0';12// updating res13if (c > res[0]) {14res[1] = res[0];15res[0] = c;16} else if (c != res[0] && c > res[1])17res[1] = c;18}19}20return res[1];21}22};