Skip to content

Instantly share code, notes, and snippets.

@thmain
Created February 24, 2016 05:37
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 thmain/65f477fb5ed9c059af35 to your computer and use it in GitHub Desktop.
Save thmain/65f477fb5ed9c059af35 to your computer and use it in GitHub Desktop.
public class OddOccuringNumber {
public static int findNumber(int [] A){
int x=0;
for(int i=0;i<A.length;i++){
x= x^A[i];
}
return x;
}
public static void main(String[] args) {
int[] A = { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7 };
System.out.println("Element appearing add number of times: " + findNumber(A));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment