Question: I'm developing a cross-platform C++11 application and I need to send a validation email to a user-entered address to make sure his email account exists and is valid.

I know there are temporary mail services like *mailinator*, but honestly I feel like a validation email is a good approach in my case since it gives people malicious intention more work to do to circumvent the system and also goes well with the rest of the application (example: having the email address allow me to automatically send status updates to users).

I have searched on the internet but I haven't been able to find a **portable**, **cross-platform** way to achieve this, at least without introducing big dependencies.

How can this issue be solved?

Answer: 
```
vector<int> solution(int N, vector<int> &A)
{
    std::vector<int> counters(N);
    auto max = 0;
    auto current = 0;

    for (auto& counter : A)
    {
        if (counter >= 1 && counter <= N)
        {
            if (counters[counter-1] < max)
                counters[counter - 1] = max;

            counters[counter - 1] += 1;

            if (counters[counter - 1] > current)
                current = counters[counter - 1];
        }
        else if (counter > N)
            max = current;

    }

    for (auto&& counter : counters)
        if (counter < max)
            counter = max;

    return counters;
}

```
Codility 100% Score using Java

```
import java.util.Arrays;
class Solution {
    public int[] solution(int N, int[] A) {
        // write your code in Java SE 8

        int[] res = new int[N];

        int counterMax = 0;
        int lastMax = 0;

        for(int i=0;i<A.length;i++){
            if( (A[i]>=1) && (A[i] <= N) ){

                if(res[A[i]-1] <= lastMax){
                    res[A[i]-1] = lastMax + 1;
                }
                else if(res[A[i]-1] > lastMax ){
                    res[A[i]-1] += 1;
                }

                if( res[A[i]-1] > counterMax ){
                    counterMax = res[A[i]-1];
                }
                //System.out.println(Arrays.toString(res));

            }
            else{

                lastMax = counterMax;
                //Arrays.fill(res,counterMax);
                //System.out.println(Arrays.toString(res));
            }
        }

        for(int i=0; i< res.length; i++){
            if(res[i] <= lastMax){
                res[i] = lastMax;
            }
        }
        return res;

    }

```