The Tribonacci sequence is defined as T(0)=0, T(1)=1, T(2)=1, T(n+3)=T(n)+T(n+1)+T(n+2). Given n, return T(n).

Input: n=4 → Output: 4Input: n=25 → Output: 1389537

Simple DP with three variables. No array needed.

class Solution { public int tribonacci(int n) { if (n == 0) return 0; if (n <= 2) return 1; int a = 0, b = 1, c = 1; for (int i = 3; i <= n; i++) { int next = a + b + c; a = b; b = c; c = next; } return c; } }