nth row of pascal's triangle leetcode
Given a non-negative index k where k ≤ 33, return the _k_th index row of the Pascal's triangle.. row adds its value down both to the right and to the left, so effectively two copies of it appear. And the other element is the sum of the two elements in the previous row. That's because there are n ways to choose 1 item.. For the next term, multiply by n-1 and divide by 2. For example, given k = 3, Return [1,3,3,1]. Math. Note that k starts from 0. But this approach will have O(n 3) time complexity. I'm interested in finding the nth row of pascal triangle (not a specific element but the whole row itself). One straight-forward solution is to generate all rows of the Pascal's triangle until the kth row. Given a non-negative index k where k ≤ 33, return the k th index row of the Pascal's triangle.. by finding a question that is correctly answered by both sides of this equation. Now update prev row by assigning cur row to prev row and repeat the same process in this loop. tl;dr: Please put your code into a
`YOUR CODE`
`YOUR CODE`