C# solution


  • 0
    K
    public class Solution {
        public IList<int> GetRow(int rowIndex) {
            
            List<int> list = new List<int>();
            List<int> temp = new List<int>();
    
            list.Add(1);
            for(int i=1;i<=rowIndex;i++)
            {
                list.Clear();
                list.Add(1);
    
                for (int j=1;j<i;j++)
                    list.Add(temp[j-1]+temp[j]);
                    
                list.Add(1);
                temp = list.ToList();
            }
            return list;
        }
    }
    

Log in to reply
 

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