My issue
complex problem even when output correct ; showing its wrong
My code
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int t = read.nextInt();
for (int i = 0; i < t; i++) {
int n = read.nextInt();
int[] a = new int[2 * n];
// Read the array elements
for (int j = 0; j < 2 * n; j++) {
a[j] = read.nextInt();
}
// Update your code below this line
System.out.println(validPrices(n, a) ? "Yes" : "No");
}
}
// Function to check if the prices are valid
static boolean validPrices(int n, int[] arr) {
Set<Integer> set = new HashSet<>();
for (int value : arr) {
if (set.contains(value)) {
return false;
} else {
set.add(value);
}
}
return true;
}
}
Learning course: Placement preparation using Java
Problem Link: Review problem - 4 Practice Problem in Placement preparation using Java - CodeChef