Skip to content

Instantly share code, notes, and snippets.

@chrislukkk
Created July 27, 2014 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislukkk/524fd7436421a8602ddb to your computer and use it in GitHub Desktop.
Save chrislukkk/524fd7436421a8602ddb to your computer and use it in GitHub Desktop.
Career cup 5.5
package Chapter5;
public class CountFlip {
public static int flipCount(int fir, int sec) {
int count = 0;
int res = fir ^ sec;
while(res != 0) {
count += res%2;
res /= 2;
}
return count;
}
public static void main(String[] args) {
System.out.println(flipCount(10, 11));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment