EasyBit Manipulation · Array

Single Number

You are given a non-empty array of integers nums. Every integer appears twice except for one. Return the integer that appears only once, in O(n) time and O(1) extra space.

nums = [3,2,3] → 2nums = [7,6,6,7,8] → 8

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Variables

The data structures the code is building

Array

Index under each cell; arrows mark the pointers

Time and space complexity

n = len(nums). The highlighted row is the solution being traced.

Keyboard: ← → step, Space play or pause. Up to 15 integers from −10000 to 10000; every value twice except one.