Print Duplicates

Report a typo

Write a program that accepts an array of integers and uses a HashMap to find the duplicates in the array. The program must print out the duplicate elements in ascending order.

Sample Input 1:

8
1 2 3 4 5 1 2 3

Sample Output 1:

1 2 3
Write a program in Java 17
import java.util.HashMap;
import java.util.Scanner;

class Main {
private static void printDuplicate(int[] map) {
// Enter your Code Here
}

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int [] map = new int[n];
for (int i = 0; i < n; ++i) {
map[i] = scanner.nextInt();
}
printDuplicate(map);
}
}
___

Create a free account to access the full topic