ACM求教
做完笔试的菜鸟又来求教了,感觉很简单的题目,为啥只过50,哪里有问题啊
![](https://uploadfiles.nowcoder.com/message_images/20220909/433184118_1662736455192/discuss_1662736454029.jpeg)
public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] chars = sc.nextLine().toCharArray(); int n= chars.length; int max =1; boolean zimu = false; for (int i = 0; i < n; i++) { if(chars[i]>='a'&&chars[i]<='z'){ zimu = true; } int count =1; for (int j = i+1; j < n; j++) { if(chars[j]-'a'==chars[j-1]-'a'+1){ count++; }else{ max = Math.max(max,count); break; } } } if(!zimu){ System.out.println(0); }else{ System.out.println(max); }