My issue
I am unable to understand which line of my code is wrong here as i am calculating the xor value of all the successive inputs and checking if they lie in the range but still that didn’t pass the test cases
My code
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
halloween(sc);
}
}
private static void halloween(Scanner sc){
int n=sc.nextInt();
int l=sc.nextInt();
int r=sc.nextInt();
int totalXor = 0;
for (int i = 0; i < n; i++) {
totalXor ^= sc.nextInt();
}
if (totalXor >= l && totalXor <= r) {
System.out.println("yes");
} else {
System.out.println("no");
}
}
}
Problem Link: Halloween Array Practice Coding Problem