Leetcode: Single Number

来源:互联网 发布:搜狗输入法mac版 编辑:程序博客网 时间:2024/05/16 00:30

http://oj.leetcode.com/problems/single-number/


class Solution {public:    int singleNumber(int A[], int n) {        // Note: The Solution object is instantiated only once and is reused by each test case.        int res=A[0];        for(int i=1;i<n;i++){            res=res^A[i];        }        return res;    }};


原创粉丝点击