Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Find the single non-duplicate

Hardware interview practice

Find the single non-duplicate

EasyBit ManipulationSystemVerilog

Every integer in an array appears exactly twice except one. Return the value that appears once.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
values = [4, 1, 2, 1, 2]
Expected output
4

Equal values cancel under XOR, leaving the value that appears only once.

What to cover

Requirements

  1. Use constant extra space.
  2. Do not sort the input.
  3. Assume exactly one singleton exists.
Continue practicing

Related questions

Bit ManipulationCompute Hamming distance→
asic.fyi · Learn silicon end to end.info@asic.fyi