Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.HashSet;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- HashSet<String> set = new HashSet<>();
- String s = sc.nextLine();
- String[] arr = s.split(" ");
- for (int i = 0; i < arr.length; i++) {
- for (int j = i + 1; j < arr.length; j++) {
- if (arr[i].equals(arr[j]))
- set.add(arr[i]);
- }
- }
- Object[] out = set.toArray();
- Arrays.sort(out);
- System.out.println(out[0]);
- }
- }
Add Comment
Please, Sign In to add comment