Given an index k, return the kth row of the Pascal's triangle.
For example, given k = 3,
Return [1,3,3,1]
.
vector<int> getRow(int rowIndex) { vector<int> res; res.push_back(1); int k = rowIndex; for(int i = 1; i <= rowIndex; ++i, --k) { double tmp = ((double)res[i-1]*k)/i; res.push_back((int)tmp); } return res; }