clueless coding // TODO: be smarter

LeetCode Pascal's Triangle II: CPP Solution



TL;DR Code Solution


vector<int> getRow(int rowIndex) {
    vector<int> result = {1};
    for (int i = 1; i <= rowIndex; i++) {
        for (int j = (int)result.size() - 1; j > 0; j--) {
            result[j] += result[j-1];
        }
        result.push_back(1);
    }
    return result;
}