### MaxCounters

 Calculate the values of counters after applying all alternating operations: increase counter by 1; set value of all counters to current maximum.My code in C++:`vector solution(int N, vector &A)``{``    int max_cnt = 0;``    int max_cnt_ref = 0;``    vector C(N);``    for (auto cmd : A) {``        if (cmd > N) {``            max_cnt = max_cnt_ref;``        }``        else {``            auto & counter = C[cmd-1];``            // verify if we have "max counter" operation pending``            if (counter < max_cnt) {``                counter = max_cnt;``            }``            // increment the counter``            ++counter;``            ``            if (counter > max_cnt_ref) {``                // set any max counter value``                max_cnt_ref = counter;``            }``        }``    }``    // if we have any "max counter" operation pending...``    if (max_cnt) {``        for (auto & counter : C) {``            // any counter is just less the max counter ``            if (counter < max_cnt) {``                counter = max_cnt;``            }``        }``    }``    return C;``}`