Created
September 11, 2015 00:09
-
-
Save cxtadment/67e230cf4be795b687bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Solution { | |
| /** | |
| * @param A : An integer array | |
| * @return : An integer | |
| */ | |
| public int singleNumberII(int[] A) { | |
| // write your code here | |
| if (A == null || A.length == 0) { | |
| return -1; | |
| } | |
| int[] bit = new int[32]; | |
| int result = 0; | |
| for (int i = 0; i < 32; i++) { | |
| for (int j = 0; j < A.length; j++) { | |
| bit[i] += A[j] >> i & 1; | |
| bit[i] %= 3; | |
| } | |
| result |= (bit[i] << i); | |
| } | |
| return result; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment