Java 1-line solution


  • 0
    X
    public class Solution {
        public int findComplement(int num) {
            return ~num-(int)-Math.pow(2,32-Integer.numberOfLeadingZeros(num));
        }
    }
    

Log in to reply
 

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