Skip to content

Commit cd02acd

Browse files
committed
测试
1 parent 225474b commit cd02acd

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

finding-mk-average/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ class MKAverage {
3838
let ret = this.total;
3939
const root = this.tree.getRoot();
4040
if (!root) throw Error("null root");
41-
// console.log(root)
41+
{
42+
const temp: [number, number][] = [];
43+
for (const node of reverseInOrderIterator(root)) {
44+
temp.push([node.value, node.count]);
45+
}
46+
console.log(JSON.stringify(temp));
47+
} // console.log(root)
4248
let k = this.k;
4349

4450
for (const node of InOrderIterator(root)) {

finding-mk-average/simple.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { assertEquals } from "https://deno.land/std@0.173.0/testing/asserts.ts";
2+
import { runScript } from "leetcode-class";
3+
import MKAverage from "./index.ts";
4+
5+
Deno.test("finding-mk-average", () => {
6+
assertEquals(
7+
runScript(
8+
[
9+
"MKAverage",
10+
"addElement",
11+
"addElement",
12+
"calculateMKAverage",
13+
"addElement",
14+
"addElement",
15+
"calculateMKAverage",
16+
"addElement",
17+
"addElement",
18+
"calculateMKAverage",
19+
"addElement",
20+
],
21+
[
22+
[3, 1],
23+
[58378],
24+
[34909],
25+
[],
26+
[94574],
27+
[29985],
28+
[],
29+
[77484],
30+
[13400],
31+
[],
32+
[41607],
33+
],
34+
MKAverage,
35+
),
36+
[null, null, null, -1, null, null, 34909, null, null, 29985, null],
37+
);
38+
});

0 commit comments

Comments
 (0)