Repository: TheAlgorithms/Java (java)

Issue:
[FEATURE REQUEST] Find the N-th Tribonacci Number missing
### What would you like to Propose?

I explored the Dynamic programming ( thealgorithms/dynamicprogramming/ ) and wasn't able to find the standard problem of finding the n-th tribonacci number in the series. Would be better if you we could add those the repo.


### Issue details

The problem involves dynamic programming to find nth tribonacci number and is a very standard problem.
I would like to Contribute to it as my first hacktoberfest Contribution. So can you pls assign it to me , I have The code ready.
problem link: https://leetcode.com/problems/n-th-tribonacci-number/description/

### Additional Information

_No response_

Pull request description:
Tribonacci - #4646
This PR introduces the `Tribonacci` class to the `dynamicprogramming` package. It implements an efficient method to compute the N-th number in the Tribonacci sequence as defined by the problem statement on LeetCode: https://leetcode.com/problems/n-th-tribonacci-number/description/.

Resolves #4646

## Changes Made

- Added `Tribonacci.java` with a static `compute` method.
- Included tests in `TribonacciTest.java`.

The `compute` method calculates the N-th Tribonacci number using an iterative approach with O(n) time complexity and O(1) space complexity, which is optimal for the constraints given.

<!--
Thank you for your contribution!
In order to reduce the number of notifications sent to the maintainers, please:
- create your PR as draft, cf. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests,
- make sure that all of the CI checks pass,
- mark your PR as ready for review, cf. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review
-->

<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
- [x] All new code is formatted with `clang-format -i --style=file path/to/your/file.java`

Patch:
diff --git a/src/main/java/com/thealgorithms/dynamicprogramming/Tribonacci.java b/src/main/java/com/thealgorithms/dynamicprogramming/Tribonacci.java
new file mode 100644
index 00000000..99f90290
--- /dev/null
+++ b/src/main/java/com/thealgorithms/dynamicprogramming/Tribonacci.java
@@ -0,0 +1,30 @@
+package com.thealgorithms.dynamicprogramming;
+
+/**
+ * The {@code Tribonacci} class provides a method to compute the n-th number in the Tribonacci sequence.
+ * N-th Tribonacci Number - https://leetcode.com/problems/n-th-tribonacci-number/description/
+ */
+public class Tribonacci {
+
+    /**
+     * Computes the n-th Tribonacci number.
+     *
+     * @param n the index of the Tribonacci number to compute
+     * @return the n-th Tribonacci number
+     */
+    public static int compute(int n) {
+        if (n == 0) return 0;
+        if (n == 1 || n == 2) return 1;
+
+        int first = 0, second = 1, third = 1;
+
+        for (int i = 3; i <= n; i++) {
+            int next = first + second + third;
+            first = second;
+            second = third;
+            third = next;
+        }
+
+        return third;
+    }
+}


Test patch:
diff --git a/src/test/java/com/thealgorithms/dynamicprogramming/TribonacciTest.java b/src/test/java/com/thealgorithms/dynamicprogramming/TribonacciTest.java
new file mode 100644
index 00000000..434a1825
--- /dev/null
+++ b/src/test/java/com/thealgorithms/dynamicprogramming/TribonacciTest.java
@@ -0,0 +1,24 @@
+package com.thealgorithms.dynamicprogramming;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test class for {@code Tribonacci}.
+ */
+public class TribonacciTest {
+
+    /**
+     * Tests the Tribonacci computation for a set of known values.
+     */
+    @Test
+    public void testKnownValues() {
+        assertEquals(0, Tribonacci.compute(0), "The 0th Tribonacci should be 0.");
+        assertEquals(1, Tribonacci.compute(1), "The 1st Tribonacci should be 1.");
+        assertEquals(1, Tribonacci.compute(2), "The 2nd Tribonacci should be 1.");
+        assertEquals(2, Tribonacci.compute(3), "The 3rd Tribonacci should be 2.");
+        assertEquals(4, Tribonacci.compute(4), "The 4th Tribonacci should be 4.");
+        assertEquals(7, Tribonacci.compute(5), "The 5th Tribonacci should be 7.");
+    }
+}