Fracture XOR Range Problem
Fracture XOR Range Problem — ExecCode Hard DSA Practice
Solve the Fracture XOR Range problem on ExecCode. Free online hard DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Problem Statement You have an array A of N integers and Q queries. Each query is L R X (1-based, both ends included). Print the largest value of A[i] XOR X among indices i from L to R. This is one array value against X. It is not the XOR of a whole subarray. Input Format There are exactly Q query lines. Output Format One integer per query. Constraints Example 1 Input Array: 1 2 3. First query uses X = 1 on the whole array: 1 XOR 1 = 0 2 XOR 1 = 3 3 XOR 1 = 2 Best is 3. Second query is only index 2 with X = 7: 2 XOR 7 = 5 Output Example 2 Input One value. 7 XOR 0 = 7. Output Example 3 Input Every value is 1. 1 XOR 0 = 1 1 XOR 1 = 0 1 XOR 1 = 0 Output
Examples
Input 3 2 1 2 3 1 3 1 2 2 7; Output 3 Input 1 1 7 1 1 0; Output 7. Input 4 3 1 1 1 1 1 4 0 2 3 1 1 1 1; Output 1 0 0
Constraints
1 ≤ N,Q ≤ 2000, 0 ≤ A[i],X ≤ 1e9.
Practice Fracture XOR Range free on ExecCode. Browse DSA problems, topic map, and placement guides.