MCPcopy Create free account
hub / github.com/careercup/ctci / bitSwapRequired

Method bitSwapRequired

java/Chapter 5/Question5_5/Question.java:6–12  ·  view source on GitHub ↗
(int a, int b)

Source from the content-addressed store, hash-verified

4
5public class Question {
6 public static int bitSwapRequired(int a, int b) {
7 int count = 0;
8 for (int c = a ^ b; c != 0; c = c >> 1) {
9 count += c & 1;
10 }
11 return count;
12 }
13
14 public static int bitSwapRequired2(int a, int b){
15 int count = 0;

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected