LeetCode – Single Number II (Java)
Problem
Given an array of integers, every element appears three times except for one. Find that single one.
Java Solution
This problem is similar to Single Number.
public int singleNumber(int[] A) { int ones = 0, twos = 0, threes = 0; for (int i = 0; i < A.length; i++) { twos = ones & A[i]; ones ^= A[i]; threes = ones & twos; ones &= ~threes; twos &= ~threes; } return ones; } 
<pre><code> String foo = "bar"; </code></pre>

alexwest11

alexwest11

alexwest11

Milos Kosanovic

nagen

dwaijam

Shailesh Agarwal