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

相关推荐

07-15 11:41
门头沟学院 Java
点赞 评论 收藏
分享
07-14 13:47
门头沟学院 Java
Lynn012:你评估好自己的位置了吗《顶尖应届》
投递小米集团等公司7个岗位
点赞 评论 收藏
分享
每晚夜里独自颤抖:要求太多的没必要理
点赞 评论 收藏
分享
人力小鱼姐:实习经历没有什么含金量,咖啡店员迎宾这种就别写了,其他两段包装一下 想找人力相关的话,总结一下个人优势,结合校园经历里有相关性的部分,加一段自我评价
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务