finally I got the right result but not accepted :(
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
for(int i =0; i < 10; i++) {
String s = reader.readLine();
list.add(s);
}
int strLength = list.get(0).length();
int strIndex = 0;
for(int i = 0; i < list.size(); i++) {
if(list.get(i).length() < list.get(i+1).length()) {
strIndex = i++;
System.out.println(strIndex-1);
break;
}
}
}
}
package com.codegym.task.task07.task0718;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Checking the order
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
for(int i =0; i < 10; i++) {
String s = reader.readLine();
list.add(s);
}
int strLength = list.get(0).length();
int strIndex = 0;
for(int i = 0; i < list.size(); i++) {
if(list.get(i).length() < list.get(i+1).length()) {
strIndex = i++;
System.out.println(strIndex-1);
break;
}
}
}
}