Skip to content

[Bit Manipulation] Single Number #151

@sudosf

Description

@sudosf

Problem

Given a non-empty array where every element appears twice except for one, find that single element. Must run in O(n) time and O(1) space.

References

Difficulty

🟢 Easy

Companies

Amazon, Google, Microsoft

Notes

Language: Java
XOR all elements. Pairs cancel out (a ^ a = 0). Result is the single element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    easyEasy difficulty

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions