C# Solution


  • 0
    U

    public class Solution {
    public IList<int> GetRow(int rowIndex) {

        List<int> nodes = new List<int>();
        List<IList<int>> list = new List<IList<int>>();
        int c =1;
        int d =0;
        nodes.Add(c);
        list.Add(nodes);
        if(rowIndex==0)
        {
            return list[rowIndex];
        }
        
        for(int i=0;i<rowIndex;i++)
        {
            //Console.WriteLine("hi");
            nodes = new List<int>();
           // Console.WriteLine(list[i].Count);
            nodes.Add(list[i][0]+d);
            for(int j=0;j<list[i].Count-1;j++)
            {
                int r = list[i][j]+list[i][j+1];
                nodes.Add(r);
            }
            nodes.Add(list[i][list[i].Count-1]+d);
            list.Add(nodes);
        }
        
        return list[rowIndex];
        
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.