public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNextLine()) { String nextLine = scanner.nextLine(); int left = 0, right = 0, maxLength = 0; while (right < nextLine.length()) { char charAt = nextLine.charAt(right++); //如果字符非数字 if (!Character.isDigit(charAt)) { left = right; continue; } //当前数字字符与前一个数字字符比较 if (right - 2 > 0 && Character.isDigit(nextLine.charAt(right - 2)) && (nextLine.charAt(right - 2) > charAt)) { left = right - 1; continue; } maxLength = Math.max(maxLength, right - left); } System.out.println(maxLength); } }
点赞

相关推荐

真烦好烦真烦:牛友太有实力了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务