I tried implementing sort using streams as below. Running locally gives me the correct result but I am getting WA. Can anybody please help?
import java.util.Arrays;
import java.util.Scanner;
class TurboSort {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int numbersToSort = sc.nextInt();
Integer[] arr = new Integer[numbersToSort];
for (int i = 0; i < numbersToSort; i++) {
arr[i] = sc.nextInt();
}
Arrays.stream(arr).sorted().distinct().forEach(x -> System.out.println(x));
}
}
thanks