알고리즘/LeetCode
[LeetCode]N-th Tribonacci Number/ DP문제
https://leetcode.com/problems/n-th-tribonacci-number/ class Solution: def tribonacci(self, n: int) -> int: dp = [j for j in range(n+1)] ans = 0 for i in range(2, n+1): dp[i] = dp[i-1] + dp[i-2] T = dp for j in range(3, n+1): T[j] = T[j-3]+T[j-2]+T[j-1] return T[n] 피보나치를 구해서 메모해놓고, 그걸 이용해서 N-th Tribonacci를 구하는 문제.
2021. 10. 1. 00:37