討論串[閒聊] 每日leetcode
共 1548 篇文章

推噓0(1推 1噓 1→)留言3則,0人參與, 1年前最新作者DJYOSHITAKA (franchouchouISBEST)時間1年前 (2024/04/24 22:19), 編輯資訊
0
0
0
內容預覽:
1137. N-th Tribonacci Number. 終於有一天我會的了. 感覺明天心態又要繼續崩了. int tribonacci(int n) {. int dp[3] = {0,1,1};. if(n<3). return dp[n];. for(int i=3; i<n+1; i++)
(還有25個字)

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者yam276 (史萊哲林的優等生)時間1年前 (2024/04/24 11:11), 1年前編輯資訊
0
0
1
內容預覽:
動態規劃基礎題. 然後Vec要根據n+來創 i32記得轉換成usize. 最常見的方法:. Code:. impl Solution {. pub fn tribonacci(n: i32) -> i32 {. if n == 0 { return 0; }. if n == 1 || n == 2
(還有581個字)

推噓0(0推 0噓 3→)留言3則,0人參與, 1年前最新作者pandix (麵包屌)時間1年前 (2024/04/24 10:53), 編輯資訊
0
0
1
內容預覽:
沒寫過快速冪版本 精華區 z-14-2-3-7-4-2 有解釋. 總之就是用轉移矩陣的快速冪把複雜度壓成log(n). Python code:. class Solution:. def tribonacci(self, n: int) -> int:. trans = [[0,1,0],[0,0
(還有441個字)

推噓2(2推 0噓 1→)留言3則,0人參與, 1年前最新作者sustainer123 (caster )時間1年前 (2024/04/24 10:46), 編輯資訊
0
0
1
內容預覽:
Python Code:. class Solution:. @cache. def tribonacci(self, n: int) -> int:. if n ==0 or n == 1:. return n. if n == 2:. return 1. return self.tribonac
(還有52個字)

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者SecondRun (南爹摳打)時間1年前 (2024/04/24 09:39), 編輯資訊
0
0
1
內容預覽:
C# code. public class Solution {. public int Tribonacci(int n). {. if (n == 0) return 0;. if (n <= 2) return 1;. int[] nums = new int[3] {0,1,1};. int
(還有144個字)