The logic is in the above gif itself. We have to do the following things.
1. Hardcode 1 at 0th and last position of every row.
2. If we are at the ith row and jth column. We can get the value of pascal[i][j].
pascal[i][j] = pascal[i-1][j-1] + pascal[i-1][j];