Skip to content

[Bit Manipulation] Single Number II #154

@sudosf

Description

@sudosf

Problem

Given an integer array where every element appears three times except for one element which appears exactly once, find that single element. Must run in O(n) time and O(1) space.

References

Difficulty

🟡 Medium

Companies

Flipkart, PhonePe, Zomato

Notes

Language: Java
Count set bits at each position modulo 3. The bit that gives remainder 1 belongs to the single element. Can also use two bitmask approach with 'ones' and 'twos'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    mediumMedium difficulty

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions