A C# solution:

IList<int> list = new List<int>();

list.Add(1);

for (int i = 1; i <= rowIndex; i++)

{

for (int j = i - 1; j >= 1; j--)

{

list[j] = list[j - 1] + list[j];

}

list.Add(1);

}

return list;

Pascal's Triangle II

Pascal's Triangle II