A charting library smooths a line with binomial weights. For a window of size k + 1, the weights are C(k, 0), C(k, 1), ..., C(k, k), which is row k of Pascal's triangle.
Write binomialRow(k) that returns that row as an array.
Input: k = 4 Output: [1,4,6,4,1]
Each inner number is the sum of the two above it in the previous row, [1, 3, 3, 1].
Input: k = 0 Output: [1]
Row 0 is just [1].
0 <= k <= 30Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #650 Binomial Smoothing Weights. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.