In: Computer Science
import java.lang.UnsupportedOperationException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// parse the number of strings
int numStrings = Integer.parseInt(sc.nextLine());
// parse each string
String[] stringsArray = new String[numStrings];
for (int i = 0; i < numStrings; i++) {
stringsArray[i] = sc.nextLine();
}
// print whether there are duplicates
System.out.println(hasDuplicates(stringsArray));
}
private static boolean hasDuplicates(String[] stringsArray) {
// TODO fill this in and remove the below line
int numWords =
}
}
import java.lang.UnsupportedOperationException; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // parse the number of strings int numStrings = Integer.parseInt(sc.nextLine()); // parse each string String[] stringsArray = new String[numStrings]; for (int i = 0; i < numStrings; i++) { stringsArray[i] = sc.nextLine(); } // print whether there are duplicates System.out.println(hasDuplicates(stringsArray)); } private static boolean hasDuplicates(String[] stringsArray) { int numWords = stringsArray.length; for(int i = 0;i<numWords;i++){ for(int j = i+1;j<numWords;j++){ if(stringsArray[i].equals(stringsArray[j])){ return true; } } } return false; } }