Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 413 Bytes

plus-minus.MD

File metadata and controls

20 lines (16 loc) · 413 Bytes

Plus Minus


https://www.hackerrank.com/challenges/plus-minus/problem

// Complete the plusMinus function below.
void plusMinus(vector<int> arr) {
    vector<int> counts = {0, 0, 0};

    for(int value: arr) {
        int index = (value == 0) ? 2 : ((value < 0) ? 1 : 0);
        ++counts[index];
    }

    for(int count: counts) {
        cout << (double)count / arr.size() << endl;
    }
}