Java 1 Liner


  • 0
    A

    Another good option is to utilize BitSet and return cardinality which checks how many bits are set.

    return BitSet.valueOf(new long[]{x ^ y}).cardinality();
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.