Bit Manipulation/Easy

Single NumberPRO PASS

Time: O(N)Space: O(1)

Step 1: Setup & Initialization - Single Number

XOR property: x ^ x = 0 and x ^ 0 = x. Identical pairs cancel out.

Array Elements & Pointers
10
[0]
20
[1]
30
[2]
40
[3]
50
[4]
Live Variables & Invariants
status:Initialized
pattern:Single Number
Step 1 / 333%
Solution Code
1
function singleNumber(nums: number[]): number {
2
  let acc = 0; for (const n of nums) acc ^= n; return acc;
3
}

Custom Test Case Runner

Input your custom values and visualize step-by-step trace

Quick Presets:

AI DSA Coach

Contextual Tutor for Single Number

Hello! I am your AI DSA Tutor for **Single Number** (Bit Manipulation). Ask me anything about this algorithm, time complexity, or request a step hint!