Share the joy
https://leetcode.com/problems/pascals-triangle-ii/
Given an index k, return the kth row of the Pascal’s triangle.
For example, given k = 3,
Return [1,3,3,1].
Analysis
Matrix like below is a pascal triangle p[][]. For row i, column j, p[i][j] it has value C(i, j) [Binomial Coefficient].
Below is the formula which can help us get C(n, m) from C(n, m – 1).
In this way, we can get elements in row i in O(n) time.
check my code on github: link