Single Number Problem

Single Number Problem — ExecCode Easy DSA Practice

Solve the Single Number problem on ExecCode. Free online easy DSA practice in Bit Manipulation. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You are given a non-empty array of integers nums where every element appears exactly twice, except for one element which appears exactly once. Implement an algorithm that finds that single element using only O(1) extra space.

Examples

Input nums = [4, 1, 2, 1, 2]; Output 4. Input nums = [2, 2, 1]; Output 1. Input nums = [1]; Output 1

Constraints

1 <= nums.length <= 50000 -1e9 <= nums[i] <= 1e9 Every element appears twice except one

Practice Single Number free on ExecCode. Browse DSA problems, topic map, and placement guides.