deno.land / x / masx200_leetcode_test@10.6.5 / product-of-the-last-k-numbers / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
export default function ProductOfNumbers() { const array = [1];
return { add(num: number): void { if (num === 0) { array[0] = 1; array.length = 1; } else { array.push(num * array[array.length - 1]); } },
getProduct(k: number): number { if (k > array.length - 1) return 0; return array[array.length - 1] / array[array.length - 1 - k]; }, };}
masx200_leetcode_test

Version Info

Tagged at
a year ago