MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / findComplement

Method findComplement

Java/number-complement.java:2–7  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

1class Solution {
2 public int findComplement(int num) {
3
4 int numberOfBits = numberOfBits(num);
5
6 return num ^ ((1 << numberOfBits) - 1);
7 }
8
9 /**
10 * Method to find out the total number of bits in a number.

Callers

nothing calls this directly

Calls 1

numberOfBitsMethod · 0.95

Tested by

no test coverage detected