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

相关推荐

头像
04-17 09:29
已编辑
湖南农业大学 后端
睡姿决定发型丫:本硕末9也是0offer,简历挂了挺多,只有淘天 美团 中兴给了面试机会,淘天二面挂,美团一面kpi面,中兴一面感觉也大概率kpi(虽然国企,但一面0技术纯聊天有点离谱吧)
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务