public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc1 = new Scanner(System.in);
ArrayList<String> list = new ArrayList<>();
for(int x = 0; x<10; x++) {
String w = sc1.nextLine();
list.add(w);
}
int index = 0;
int max = 0;
int min = 0;
for (String y : list) {
if (y.length() > max) {
max = y.length();
int x = list.indexOf(y);
}
for(String r : list) {
if (r.length() < min) {
min = r.length();
int p = list.indexOf(r);
}
}
if (x<p) {
System.out.println(max);
}
else {
System.out.println(min);
}
}
}
}
package com.codegym.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc1 = new Scanner(System.in);
ArrayList<String> list = new ArrayList<>();
for(int x = 0; x<10; x++) {
String w = sc1.nextLine();
list.add(w);
}
int index = 0;
int max = 0;
int min = 0;
for (String y : list) {
if (y.length() > max) {
max = y.length();
int x = list.indexOf(y);
}
for(String r : list) {
if (r.length() < min) {
min = r.length();
int p = list.indexOf(r);
}
}
if (x<p) {
System.out.println(max);
}
else {
System.out.println(min);
}
}
}
}