Note that k starts from 0. Given a non-negative index k where k ≤ 33, return the k th index row of the Pascal's triangle.. However, it can be optimized up to O(n 2) time complexity. 4. Note that the row index starts from 0. The mainly difference is it only asks you output the kth row of the triangle. Subsequent row is created by adding the number above and to the left with the number above and to the right, treating empty elements as 0. # # Note that the row index starts from 0. It’s also good to note that if we number the rows beginning with row 0 instead of row 1, then row n sums to 2n. This is the function that generates the nth row based on the input number, and is the most important part. Now update prev row by assigning cur row to prev row and repeat the same process in this loop. That's because there are n ways to choose 1 item.. For the next term, multiply by n-1 and divide by 2. The run time on Leetcode came out quite good as well. One straight-forward solution is to generate all rows of the Pascal's triangle until the kth row. Given num Rows, generate the firstnum Rows of Pascal's triangle. 118: Pascal’s Triangle Yang Hui Triangle Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle. There are n*(n-1) ways to choose 2 items, and 2 ways to order them. Example: In each row, the first and last element are 1. Note that the row index starts from 0. In Pascal's triangle, each number is the sum of the two numbers directly above it. The following is an efficient way to generate the nth row of Pascal's triangle.. Start the row with 1, because there is 1 way to choose 0 elements. Given a non-negative index k where k ≤ 33, return the _k_th index row of the Pascal's triangle.. Example: Input: 3 Output: [1,3,3,1] tl;dr: Please put your code into a
`YOUR CODE`