deno.land / x / masx200_leetcode_test@10.6.5 / JEj789 / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function minCost(costs: number[][]): number { const n = costs.length;
let dp = costs[0];
for (let i = 1; i < n; i++) { const dp2: typeof dp = []; for (let j = 0; j < 3; j++) { const min = Math.min(dp[(j + 1) % 3], dp[(j + 2) % 3]); dp2.push(min + costs[i][j]); } dp = dp2; }
return Math.min(...dp);}export default minCost;
masx200_leetcode_test

Version Info

Tagged at
a year ago