FastPrepXOR Gate with Multiplexers
Problems/XOR Gate with Multiplexers

XOR Gate with Multiplexers

AMD logoAMD● EasyNEW GRADPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks to implement an XOR gate using MUX, without an interface, MUX arity or gate-count bound. This exercise authors a2:1 MUX software model and batch interface while keeping the MUX-only construction requirement. Tests verify behavior, not RTL or netlist structure. Approximate source match: 75%.

Build an XOR gate using multiplexers and evaluate it for every input pair in inputs. Each row is [a,b], with both values either0 or1. Return the resulting bit for each row in the same order.

For this practice, use a two-input multiplexer mux(s,d0,d1): it returns d0 when s=0, otherwise d1. Compose the gate only from this primitive, wires and constants0 and1. You may implement the primitive with a conditional; do not replace the circuit with direct logical or bitwise gate operators or an arithmetic shortcut.

The automated tests check the truth-table behavior. The construction restriction is an implementation requirement explained by the reference circuits; this software exercise does not compile HDL or audit a synthesized gate netlist.

Function

xorWithMux(inputs: int[][]) → int[]

Examples

Example 1

inputs = [[0,0],[0,1],[1,0],[1,1]]return = [0,1,1,0]

The XOR truth table in order00,01,10,11 is 0,1,1,0.

Example 2

inputs = []return = []

There are no input pairs, so return an empty array.

Example 3

inputs = [[1,0],[1,1],[0,1]]return = [1,0,1]

Evaluate each pair independently, preserving the input order.

Constraints

  • 0 <= inputs.length <= 10000.
  • Every row has exactly 2 entries.
  • Every entry is an integer from 0 to 1.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public int[] xorWithMux(int[][] inputs) {
    return new int[0];
}
Checking account…