单次出现的元素
single-number
http://www.nowcoder.com/questionTerminal/0bc646909e474ac5b031ec6836a47768
哇哈哈,位运算大法好。。。
两个异或=开心^^
//
// Created by jt on 2020/8/8.
//
#include
using namespace std;
class Solution {
public:
/**
*
* @param A int整型一维数组
* @param n int A数组长度
* @return int整型
*/
int singleNumber(int* A, int n) {
// write code here
int result = 0;
for (int i = 0; i < n; ++i) {
result ^= A[i];
}
return result;
}
};刷遍天下无敌手 文章被收录于专栏
秋招刷题历程