N-th Tribonacci Number
EasyDynamic Programming1d dp
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
The Tribonacci sequence is defined by T0 = 0, T1 = 1, T2 = 1, and
T(n) = T(n-1) + T(n-2) + T(n-3) for every n >= 3.
Given n, return T(n). For the allowed range of n the answer fits in a signed 32-bit integer.
Examples
Input: n = 4
Output: 4
T3 = 0 + 1 + 1 = 2, and T4 = 1 + 1 + 2 = 4.
Input: n = 25
Output: 1389537
Continuing the recurrence up to index 25 gives 1389537.
Constraints
- 0 <= n <= 37
- The answer is guaranteed to fit in a 32-bit signed integer
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.