标签:blog for ar 2014 art div amp log on
int singleNumber(int A[], int n) { int once = 0; int twice = 0; int three = 0; for (int i = 0; i < n; ++i) { //在计算新的once 前,计算twice twice |= once & A[i]; //计算新的once once ^= A[i]; three = ~(once & twice); //将3次的1都清理掉 once &= three; twice &= three; } return once; }
标签:blog for ar 2014 art div amp log on
原文地址:http://www.cnblogs.com/hrhguanli/p/3929423.html