File tree 1 file changed +0
-32
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +0
-32
lines changed Original file line number Diff line number Diff line change 3
3
import java .util .ArrayList ;
4
4
import java .util .List ;
5
5
6
- /**
7
- * 1009. Complement of Base 10 Integer
8
- *
9
- * Every non-negative integer N has a binary representation.
10
- * For example, 5 can be represented as "101" in binary,
11
- * 11 as "1011" in binary, and so on.
12
- *
13
- * Note that except for N = 0, there are no leading zeroes in any binary representation.
14
- *
15
- * The complement of a binary representation is the number in binary you get when
16
- * changing every 1 to a 0 and 0 to a 1. For example, the complement of "101" in binary is "010" in binary.
17
- *
18
- * For a given number N in base-10, return the complement of it's binary representation as a base-10 integer.
19
- *
20
- * Example 1:
21
- * Input: 5
22
- * Output: 2
23
- * Explanation: 5 is "101" in binary, with complement "010" in binary, which is 2 in base-10.
24
- *
25
- * Example 2:
26
- * Input: 7
27
- * Output: 0
28
- * Explanation: 7 is "111" in binary, with complement "000" in binary, which is 0 in base-10.
29
- *
30
- * Example 3:
31
- * Input: 10
32
- * Output: 5
33
- * Explanation: 10 is "1010" in binary, with complement "0101" in binary, which is 5 in base-10.
34
- *
35
- * Note:
36
- * 0 <= N < 10^9
37
- * */
38
6
public class _1009 {
39
7
public static class Solution1 {
40
8
public int bitwiseComplement (int N ) {
You can’t perform that action at this time.
0 commit comments