Advertisement
sweet1cris

Untitled

Jan 9th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public class Solution {
  2.     public int singleNumberII(int[] A) {
  3.         if (A == null || A.length == 0) {
  4.             return -1;
  5.         }
  6.         int result=0;
  7.         int[] bits=new int[32];
  8.         for (int i = 0; i < 32; i++) {
  9.             for(int j = 0; j < A.length; j++) {
  10.                 bits[i] += A[j] >> i & 1;
  11.                 bits[i] %= 3;
  12.             }
  13.  
  14.             result |= (bits[i] << i);
  15.         }
  16.         return result;
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement