Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Single Number

Easy
bit-manipulationarray

Every element of nums appears exactly twice except one, which appears once. Find it in O(n) time and O(1) space.

Input: one line of space-separated integers. Output: the single number.

Example 1
Input:
2 2 1
Output:
1
Example 2
Input:
4 1 2 1 2
Output:
4

Constraints

  • 1 ≤ nums.length ≤ 3·10^4 (odd)
  • Each value appears twice except one.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.