class Solution {
//using xor bit manipulation
public:
int singleNumber(int A[], int n) {
// Note: The Solution object is instantiated only once and is reused by each test case.
int res = 0;
for(int i = 0; i < n; ++i)
res ^= A[i];
return res;
}
};[LeetCode]Single Number
使用位运算解决单一数字问题
最新推荐文章于 2020-07-25 00:49:52 发布
本文介绍了一种使用位运算解决单一数字问题的方法,并通过示例代码展示了解决过程。
3734

被折叠的 条评论
为什么被折叠?



