namespace _118._Pascal_s_Triangle; public class Solution { public IList> Generate(int numRows) { List> triangle = new List>() { new List { 1 } }; if (numRows > 1) triangle.Add(new List() { 1, 1 }); numRows -= 2; while (numRows-- > 0) { IList prev = triangle[^1]; int nextCount = prev.Count; List row = new List() { 1 }; for (int i = 1; i < nextCount; i++) { row.Add(prev[i - 1] + prev[i]); } row.Add(1); triangle.Add(row); } return triangle; } }