My issue
need the code
My code
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while (t > 0) {
int n = scanner.nextInt();
Set<Integer> s = new HashSet<>();
for (int i = 0; i < n; i++) {
int wi = scanner.nextInt();
s.add(wi - i);
}
if (s.size() == n) {
System.out.println(n);
} else {
System.out.println(1);
}
t--;
}
}
}
Learning course: DSA using Java
Problem Link: Just a Graph Practice Problem in DSA using Java - CodeChef