Bit Manipulation: Lonely Integer

  • + 12 comments

    Java:

    public static int lonelyInteger(int[] a) {
        int value = 0;
    
        for (int i : a) {
            value ^= i;
        }
        return value;
    }