본문 바로가기
python-algorithm

leetcode 1137. N-th Tribonacci Number

by 무적김두칠 2024. 4. 25.

https://leetcode.com/problems/n-th-tribonacci-number/description/?envType=daily-question&envId=2024-04-24

 

1
2
3
4
5
6
class Solution:
    def tribonacci(self, n: int-> int:
        answer = [011]
        for i in range(2, n):
            answer.append(answer[i] + answer[i - 1+ answer[i - 2])
        return answer[n]
cs
반응형

댓글