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); } }
点赞

相关推荐

09-28 22:01
已编辑
广西科技大学 IT技术支持
合适才能收到offe...:找桌面运维?
点赞 评论 收藏
分享
爱吃烤肠的牛油最喜欢...:50K是ssp了估计,ssp的人家多厉害都不用说,每年比例大概在百分之5左右
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务