All problems
0467EasyMathDynamic ProgrammingMemoization

Three-Day Dispatch Ladder

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1137N-th Tribonacci Number

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 courier depot keeps a daily log of how many vans it sent out, numbering days from 0.

The log opens with a quiet day: no vans left the yard on day 0. Exactly one van left on day 1, and exactly one left on day 2. From day 3 onward the depot's rule is fixed: the count for a day is the three counts of the days right before it added together.

Given a day number day, return the number of vans the log shows for that day.

Examples

Example 1

Input
day = 0
Output
0

Day `0` is the quiet day the log opens with, so nothing left the yard.

Example 2

Input
day = 7
Output
24

Days `4` through `6` show 4, 7 and 13 vans, and day `7` follows from those three.

Example 3

Input
day = 26
Output
2555757

The counts climb quickly once the depot's rule takes over, and day `26` is a six-figure count.

Constraints

  • 0 <= day <= 37
  • The count for the requested day is guaranteed to fit in a signed 32-bit integer, so it is at most 2^31 - 1.

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 vans_dispatched(day: int) -> int:
Java
public int vansDispatched(int day)
September 7
Apply