Maximum XOR Between Two Arrays
Updated
Problem statement
You are given two non-empty arrays of non-negative integers, arr1 and arr2.
Choose one value A from arr1 and one value B from arr2. Return the maximum possible value of A xor B over all such cross-array pairs.
Function
maximumXorBetweenArrays(arr1: int[], arr2: int[]) → intExamples
Example 1
arr1 = [6,6,0,6,8,5,6]arr2 = [1,7,1,7,8,0,2]return = 15Choosing 8 from arr1 and 7 from arr2 gives 8 xor 7 = 15.
Example 2
arr1 = [25,10,2]arr2 = [8,5,3]return = 28Choosing 25 and 5 gives 25 xor 5 = 28, the largest cross-array value.
Constraints
1 <= arr1.length, arr2.length <= 10000 <= arr1[i], arr2[i] <= 10^9
More InMobi Onsite Interview questions
- Russian Doll EnvelopesONSITE INTERVIEW · Seen Jul 2026
- Minimum and Maximum with Optimal ComparisonsONSITE INTERVIEW · Seen Dec 2025
- Minimum Edges to Connect All ComponentsONSITE INTERVIEW · Seen Dec 2025
- Shortest Path Visiting All NodesONSITE INTERVIEW · Seen Sep 2025
- Maximum Sum of Non-Adjacent Tree NodesONSITE INTERVIEW · Seen Jan 2022
- Word SquaresONSITE INTERVIEW · Seen Jan 2022
- Maximum Length Pair ChainONSITE INTERVIEW · Seen Jul 2021
- Top View of a Binary TreeONSITE INTERVIEW · Seen Jul 2021
- Trapping Rain WaterONSITE INTERVIEW · Seen May 2021
- Validate Binary Search TreeONSITE INTERVIEW · Seen May 2021
Similar questions at other companies
- Optimal Account BalancingAmazon · ONSITE INTERVIEW
- Hybrid Run-Length and Bit-Packing EncoderDatabricks · ONSITE INTERVIEWDatabricks interview questions
- Word Break IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Longest Word Containing Another InputMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Word Search IIKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
- Maximize XOR-AND-XOR over Three SubsequencesGoogle · ONSITE INTERVIEWGoogle interview questions
- Keyboard Autocomplete SuggestionsLyft · ONSITE INTERVIEWLyft interview questions
- Find the Two Unique NumbersZomato / Eternal · ONSITE INTERVIEWZomato / Eternal interview questions
- Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
- Smallest Sufficient TeamExpedia · ONSITE INTERVIEWExpedia interview questions