C#: O(n) time and space


#1

I don’t know why in the complete solution we have an additional loop. So, it is O(n^2) in it.

class Solution {
    public List<int> getRow(int A) {
        A++;
        var il = new List<int>();
        int C = 1;  // used to represent C(line, i)
        for (int i = 1; i <= A; i++)
        {
            il.Add(C);
            C = C * (A - i) / i;
        }
        return il;
    }
}