Question: I'm trying to compare 2 large vectors(integer) i.e. at each entry, see if two vectors have the same element or not. I've tried a few things, using an iterator to do the comparision and a simple for loop. Both works but I need something that will speed things up as I have to compare a lot of vectors. What's the best way to do that in C++?? Many thanks in advance!

```
typedef vector<int> fingerprint;

double aakernel(fingerprint a,fingerprint b, double h){

    double diff = 0;
    vector<int>::iterator dd = a.begin();
    vector<int>::iterator ee = b.begin();

    for(; dd != a.end() && ee != b.end() ;++dd, ++ee){ /*option one*/
        if (*dd!=*ee){
            diff++;
        }

    }

    for (int dd=0;dd<int(a.size());dd++){ /*option two*/
        if (a[dd]!=b[dd]){
            diff++;
        }
    }
    double due = (h/(1-h));
    double q = -log(due)*diff;
    double K = exp(q);
    return (K);
}

```

Answer: 
In case the two `fingerprint` values are usually the same, it may help if you first do a

```
memcmp(&a[0], &b[0], a.size() * sizeof(int))

```

To test whether there's any difference between the two arrays at all. Only if there's any difference you go and look how many differences there are.
Thanks a lot for all the different solutions! Much appreciated. I used diff as a double because at the end of the calculation it needs to be put in a kernel function and coming from a Python background I thought it would be better to assign it double in the first place but I might be wrong here but thanks for the comment! 

Also, to elaborate on the fingerprint (which I should have done in the first place, my apologies) or maybe bitstring is a better word for it, each bit contains 1 or 0 in my case and I need to compare at each index whether the two bitstring are the same or not. Many thanks again for the solutions I'll try and see which one would help speed things up! Thanks a lot guys!