A 0ms C++ Solution


  • 0
    Y
    class Solution {
    public:
        vector<int> getRow(int rowIndex) {
            vector<int> line = {1};
            vector<int> temp = line;
            int loop = 1;
            while(loop <= rowIndex) {
                for(int i = 1; i < temp.size(); i++) {
                    line[i] = temp[i] + temp[i - 1];
                }
                line.push_back(1);
                loop += 1;
                temp = line;
            }
            return line;
        }
    };

Log in to reply
 

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