Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/careercup/ctci
/ bitSwapRequired2
Method
bitSwapRequired2
java/Chapter 5/Question5_5/Question.java:14–20 ·
view source on GitHub ↗
(int a, int b)
Source
from the content-addressed store, hash-verified
12
}
13
14
public
static
int
bitSwapRequired2(
int
a,
int
b){
15
int
count = 0;
16
for
(
int
c = a ^ b; c != 0; c = c & (c-1)) {
17
count++;
18
}
19
return
count;
20
}
21
22
public
static
void
main(String[] args) {
23
int
a = 23432;
Callers
1
main
Method · 0.95
Calls
no outgoing calls
Tested by
no test coverage detected