All problems
0735EasyArrayDynamic Programming

Row Of The Drop Board

Tracked in this browser only
Write code

Trains the technique from

LeetCode 119Pascal's Triangle II

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A drop board is laid out as a triangle of cells. The top row is row 0 and holds a single cell containing 1.

Each row below has one cell more than the row above it. The cell at each end of a row holds 1, and every other cell holds the total of its two neighbours in the row above.

Given level, return the contents of row level, read from left to right.

Examples

Example 1

Input
level = 4
Output
[1, 4, 6, 4, 1]

Row 3 reads 1, 3, 3, 1. Row 4 is one cell longer, holds 1 at each end, and its inner cells hold 1 + 3 = 4, 3 + 3 = 6 and 3 + 1 = 4.

Example 2

Input
level = 6
Output
[1, 6, 15, 20, 15, 6, 1]

Row 5 reads 1, 5, 10, 10, 5, 1, so the inner cells of row 6 hold 6, 15, 20, 15 and 6, with 1 at each end.

Example 3

Input
level = 8
Output
[1, 8, 28, 56, 70, 56, 28, 8, 1]

Row 7 reads 1, 7, 21, 35, 35, 21, 7, 1, and totalling its neighbouring pairs gives the inner cells 8, 28, 56, 70, 56, 28 and 8, with 1 at each end.

Constraints

  • 0 <= level <= 33
  • Every number in the answer fits in a signed 32-bit integer.

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def board_row(level: int) -> list[int]:
Java
public List<Integer> boardRow(int level)
September 7
Apply