A new circuit has been designed that takes three inputs: A, B, and N.
The task is to find an integer X such that X < 2^N and the product of (A XOR X) and (B XOR X) is maximized.
Return the result modulo 10^9 + 7.
Note that XOR represents the bitwise XOR operator.
Examples
01 · Example 1
A = 4 B = 6 N = 3 return = 35
We can choose X = 3: (A XOR X) = 7 and (B XOR X) = 5. The product is 35, and 35 modulo 10^9 + 7 is 35.
Constraints
0 <= N <= 301 <= A < 2^N1 <= B < 2^N
More Microsoft problems
- Neural Network Subnetwork StrengthOA · Seen Jun 2026
- Maximum Escape Game ScoreOA · Seen Jun 2026
- Minimum Cost K-Capable ModelsOA · Seen Jun 2026
- Rank Open BusinessesPHONE SCREEN · Seen May 2026
- Retain Top K ValuesPHONE SCREEN · Seen May 2026
- In-Memory SQL with CSV InitializationONSITE INTERVIEW · Seen May 2026
- Order Records by Matching Start and EndONSITE INTERVIEW · Seen May 2026
- Recover Corrupted Master PageONSITE INTERVIEW · Seen Feb 2026
public int xorMultiplication(int A, int B, int N) {
// write your code here
}
A4
B6
N3
expected35
checking account