https://leetcode.com/problems/pascals-triangle/
파스칼 삼각형의 행들 반환
1) 1, 2번째 base로 넣기
2) 1 앞뒤로 붙이고, 중간은 이전 리스트에서 각각 합으로 구하기
public class Solution {
public IList<IList<int>> Generate(int numRows) {
List<IList<int>> answerList = new List<IList<int>>();
answerList.Add(new List<int> {1});
if (numRows == 1) return answerList;
answerList.Add(new List<int> {1, 1});
if (numRows == 2) return answerList;
for (int i = 2; i < numRows; i++)
{
IList<int> prevList = answerList[answerList.Count - 1];
List<int> currList = new List<int>();
currList.Capacity = i;
currList.Add(1);
for (int j = 0; j < prevList.Count; j++)
{
if (j == prevList.Count - 1) break;
currList.Add(prevList[j] + prevList[j + 1]);
}
currList.Add(1);
answerList.Add(currList);
}
return answerList;
}
}