題面1137. 第 N 個泰波那契數 - 力扣(LeetCode)
題解同2024.9.6 leetcode 70 爬樓梯 (雜湊表/動態規劃) - 樹寶2021 - 部落格園 (cnblogs.com)
class Solution { public: int tribonacci(int n) { unordered_map<int,int> umap; umap.insert({0,0}); umap.insert({1,1}); umap.insert({2,1}); for(int i = 3; i <= 37; i++) { umap.insert({i, umap[i-1]+umap[i-2]+umap[i-3]}); } return umap[n]; } };