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 {
//write your code here
ArrayList<String> list = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0 ; i < 10 ; i++)
{
list.add(reader.readLine());
}
int temp = list.get(0).length();
for(int i = 1 ; i < list.size() ; i++)
{
if(list.get(i).length() <= temp)
{
System.out.println(i);
break;
}
}
}
}
Last condition is not verified. Can anyone please check what's wrong with the code
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Learner
18 September 2018, 05:31useful
Display the index of first element that violates. Your logic is incorrect.
Take this input for example: aa, bbb, ccc, d and test your code.
Index of ccc should be the correct output.
+1
Khurram
18 September 2018, 05:45
thanks man, i figured out what I was doing wrong. its working now
0