We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Interview Preparation Kit
  3. Miscellaneous
  4. Maximum Xor

Maximum Xor

Problem
Submissions
Leaderboard
Discussions
Editorial

You are given an array of elements. A list of integers, is given as an input, find the maximum value of for all , where represents xor of two elements.

Note that there are multiple test cases in one input file.

For example:





Function Description

Complete the maxXor function in the editor below. It must return an array of integers, each representing the maximum xor value for each element against all elements of .

maxXor has the following parameter(s):

  • arr: an array of integers
  • queries: an array of integers to query

Input Format

The first line contains an integer , the size of the array .

The second line contains space-separated integers, from .

The third line contain , the size of the array .

Each of the next lines contains an integer where .

Constraints

Output Format

The output should contain lines with each line representing output for the corresponding input of the testcase.

Sample Input 0

3
0 1 2
3
3
7
2

Sample Output 0

3 
7 
3 

Explanation 0










Sample Input 1

5
5 1 7 4 3
2
2
0

Sample Output 1

7 
7 

Explanation 1











Sample Input 2

4
1 3 5 7
2
17
6

Sample Output 2

22
7

Explanation 2









Author

rock19

Difficulty

Medium

Max Score

55

Submitted By

12498

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website