Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 588 Bytes

pascals-triangle-ii.md

File metadata and controls

25 lines (19 loc) · 588 Bytes

Solution

    class Solution {
    public:
        vector<int> getRow(int rowIndex) {
            vector<int> ans(rowIndex + 1);
            for(int i = 0; i <= rowIndex; i++) {
                if(i == 0 || i == rowIndex)
                    ans[i] = 1;
                else
                    ans[i] = (int)(((long)ans[i - 1] * (long)(rowIndex + 1 - i)) / i);
            }
            return ans;
        }
    };