public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
int b = 0, c = 0;
ArrayList<String> list = new ArrayList<String>();
Scanner scan = new Scanner(System.in);
for(int i = 0; i < 10; i++){
list.add(scan.nextLine());
}
int min = list.get(0).length();
int max = list.get(0).length();
for(int i = 0; i < 10; i++){
if(min > list.get(i).length()){
min = list.get(i).length();
b = i;
}
if(max < list.get(i).length()){
max = list.get(i).length();
c = i;
}
}
if(b < 9 - c)
System.out.println(list.get(b));
else
System.out.println(list.get(c));
}
}
What's wrong in this??please help
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Anuj Jaiswal
6 June 2019, 15:58
well bro i try to post my question but it always shows that invalid request.
and (b<9-c) is because suppose c will be getting a value of 8(c=8) and b will be getting a value of 3(b=3),talking about their indexes.then c index should be printed that the b one.
0
Guadalupe Gagnon
6 June 2019, 14:44
What is line 23 supposed to do? It should be if(b < c).
Also, do not copy and paste code like this, just use the slider. There is a lot of information not here that we need to answer questions:
.
.
![]()

0