XOR Multiplication
Updated
Problem statement
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.
Function
xorMultiplication(A: int, B: int, N: int) → intExamples
Example 1
A = 4B = 6N = 3return = 35We 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 Online Assessment questions
- Authentication SystemOA · Seen Nov 2026
- Maximum String OperationsOA · Seen Nov 2026
- Minimum Cost to Process Priority TasksOA · Seen Nov 2026
- Most Visited Sprint MarkerOA · Seen Nov 2026
- Maximum Escape Game ScoreOA · Seen Nov 2026
- Count Subarrays with a Perfect-Square ProductOA · Seen Nov 2026
- Maximum Interactive Team SizeOA · Seen Nov 2026
- Maximize Pipeline Throughput Under a Scaling BudgetOA · Seen Nov 2026
- Minimum Cost K-Capable ModelsOA · Seen Nov 2026
- Find Available Meeting RoomsOA · Seen Oct 2026
Similar questions at other companies
- Minimum Halvings for Alternating ParityIBM · OAIBM interview questions
- Minimum Operations To Reduce To ZeroUber · OAUber interview questions
- Minimum Power-of-Two AdjustmentsNVIDIA · OANVIDIA interview questions
- IP Address to CIDR BlocksOpenAI · PHONE SCREENOpenAI interview questions
- IP Range to CIDR BlocksAirbnb · PHONE SCREENAirbnb interview questions
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions
- Knights, Knaves and Their StatementsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Minimum No-Repeat Segments After One Character RemovalSalesforce · OASalesforce interview questions
- Repeated Mirror XORMathWorks · OAMathWorks interview questions
Microsoft interview experiences
- Microsoft OA Questions, October 2026: 4 Experiences
- Microsoft Experienced SWE Phone Screen: 1 Experience
- Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
- Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
- Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
- Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)