【second】Pascal's Triangle II

 

    vector<int> getRow(int rowIndex) {
        // Note: The Solution object is instantiated only once and is reused by each test case.
        if(rowIndex<0)
            return vector<int>();
        
        vector<int> res(rowIndex+1);
        res[0] = 1;
        for(int i=1;i<=rowIndex;i++)
        {
            res[i] = 1;
            for(int j=i-1;j>0;j--)
                res[j] += res[j-1];
            res[0] = 1;
        }
        
        return res;
        
    }

  

posted @ 2013-10-23 14:30  summer_zhou  阅读(130)  评论(0编辑  收藏  举报