• + 0 comments

    C++ ans

    vector stones(int n, int a, int b) { if (n <= 1) { return {0}; }

    set<int> current;
    
    for (int i = 0; i < n; i++) {
        int value = i * a + (n - 1 - i)*b; // i times a and (n-1-i) times b
        current.insert(value);
    }
    vector<int> result(current.begin(), current.end());
    
    return result;
    

    }