class Solution { public: int maxValue(string s, int k) { // write code here int n = s.size(); int Max = 0; string a = ""; for (int i = 0; i < n; i++) { a += s[i]; if (a.size() == k) {//若a的字符串长度等于k进入判断; Max=max(Max,stoi(a));//利用stoi函数直接转化为数字,并与Max的值作比较; a.erase(a.begin());//删除首位字符; } } return Max; } };