Write a method that given an integer n, would return the corresponding row n of pascal's triangle. Example Input: 4, Output: 1 4 6 4 1vector<int> PascalTriangle(unsigned int n)
{
vector<int> res;
res.push_back(1);
if (n == 0)
return res;
if (n == 1)
{
res.push_back(1);
return res;
}
vector<int> temp = PascalTriangle(n - 1);
for (int i = 0; i < n - 1; i++)
res.push_back(temp[i] + temp[i + 1]);
res.push_back(1);
return res;
} |