Share my concise code


  • 0
    O
    class Solution {
    public:
        vector<int> getRow(int rowIndex) {
            vector<int> tri;
            for (int i = 0; i <= rowIndex; i++) {
                for (int j = tri.size() - 1; j > 0; j--)
                    tri[j] += tri[j - 1];
                tri.push_back(1);
            }
            return tri;
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.