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.
you don't need to write it by yourself since stl have certain functions to do that, check [this](http://www.cplusplus.com/reference/algorithm/find_if/)

You can check more algorithm here:

<http://www.cplusplus.com/reference/algorithm/>