/**
* @author xienl
* @description 最大值
* @date 2022/7/22
*/
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
System.out.println(solution.maxValue("2473884163", 4));
}
public int maxValue (String s, int k) {
// write code here
int m = s.length();
if (m == k){
return Integer.parseInt(s);
}
int left = 0;
int res = 0;
while (left < m - k){
res = Math.max(res, getInt(s, left, k + left));
left++;
}
return res;
}
private int getInt(String s, int start, int end){
return Integer.parseInt(s.substring(start, end));
}
}